0

I'd like to load a table and print it by using xtable library. Unfortunately this table has some conditions on the first column that are not parsed corrctely. and some "$" appear on it

here's the table

A>1;Y;N;Y;N;N;N
B>2;N;N;Y;N;N;N
C;B;A;B;B;A;A

and here's what I've tried so far

library("xtable")
T <- read.csv("table.csv", header=FALSE, sep=";", stringsAsFactors=FALSE)
xT <- print(xtable(T))

here's what I got

% latex table generated in R 3.2.2 by xtable 1.8-0 package
% Mon Dec  7 16:33:56 2015
\begin{table}[ht]
\centering
\begin{tabular}{lllllll}
  \hline
  \hline
  A$>$1 & Y & N & Y & N & N & N \\ 
  B$>$2 & N & N & Y & N & N & N \\ 
  C & B & A & B & B & A & A \\ 
  \hline
\end{tabular}
\end{table}
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Stefano
  • 361
  • 1
  • 4
  • 21
  • But this allows the greater sign to be parsed correctly by latex. Have you tried generating the pdf...it comes out as B>2 etc – user20650 Dec 07 '15 at 18:08
  • I'm actually using it as an html output and there I see the dollars symbols. and I'd like to avoid it. – Stefano Dec 08 '15 at 08:36
  • Sorry i am not sure i understand... are you displaying the unevaluated latex code in a html doc and dont want the dollars.. try `print(xtable(T), sanitize.text.function = identity)` , or are you wanting the code in html `print(xtable(T), type="html") `, where the greater sign is changed to html *&gt.) – user20650 Dec 08 '15 at 13:07
  • Thanks a lot!! it works by using `sanitize.text.function = identity`. while with `type=html` it works as well but it displays everything with a not good look outfit. thanks a again! and sorry if I was not enough precise. – Stefano Dec 08 '15 at 16:53
  • 1
    in fact by using `type="html"` I can see the table without the dollar symbols but the table is shown with a not nice outlook. (everything is sweezed) while apparently with `sanitize.text.function` all the entries have enough room and everything is easily readable. – Stefano Dec 09 '15 at 16:08

0 Answers0