Hi, maybe my question is not typical. I want to make R table-kind output to be readable immediately in Latex but I am struggling with symbol '\' needed for instance in '\hline'. For example when 'Table' is a matrix class object: cat("&",Table[1,1], "&",Table[1,2], "\n");flush.console() cat("\hline \n");flush.console() cat("&",Table[2,1], "&",Table[2,2], "\n");flush.console() etc, to have specific output which I can paste (or save) in latex readible format. but '\' was not accepted by R. Is there any way to over come this obstacle or maybe other way to 'implement' R table output into latex format thank you in advance rob -- View this message in context: http://www.nabble.com/R-Latex-question-tp15980281p15980281.html Sent from the R help mailing list archive at Nabble.com.
threshold wrote:> Hi, maybe my question is not typical. I want to make R table-kind output to > be readable immediately in Latex but I am struggling with symbol '\' needed > for instance in '\hline'. For example when 'Table' is a matrix class object: > > cat("&",Table[1,1], "&",Table[1,2], "\n");flush.console() > cat("\hline \n");flush.console() > cat("&",Table[2,1], "&",Table[2,2], "\n");flush.console() > > etc, to have specific output which I can paste (or save) in latex readible > format. > > but '\' was not accepted by R. Is there any way to over come this obstacle > or maybe other way to 'implement' R table output into latex format > > thank you in advance > rob >Double the backslashes and/or have a look at the "xtable" package. -- O__ ---- Peter Dalgaard ?ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
On Tue, 2008-03-11 at 10:23 -0700, threshold wrote:> cat("\hline \n");flush.console()you need to double the backslashes, as in cat("\\hline \n");flush.console() as in> cat("\\hline \n");flush.console()\hline The warning when using just one kind of hints at what is going on:> cat("\hline \n");flush.console()hline Warning messages: 1: '\h' is an unrecognized escape in a character string 2: unrecognized escape removed from "\hline \n" You may want to take a look the packages Hmisc and xtable, which both have great facilities for doing latex output from all kinds of R objects. Regards, markus -- Markus Jantti Abo Akademi University mjantti at abo.fi http://www.iki.fi/~mjantti
Possibly Parallel Threads
- Using R-0.65.0 under ESS on Unix
- Sweave special token \\ from R to latex
- weighted kernel density estimate
- using poly in a linear regression in the presence of NA f ails (despite subsetting them out)
- using poly in a linear regression in the presence of NA f ails (despite subsetting them out)