[R] Error while generating latex table from sweave and R?

Uwe Ligges ligges at statistik.tu-dortmund.de
Wed Apr 18 12:48:35 CEST 2012



On 18.04.2012 09:43, Manish Gupta wrote:
> Hi ,
>
> I am generating one table without using latex.
>
> for (i in 1:LCol3) {
>
> df<- data.frame(matrix(ncol = 6, nrow = 0))
> datavec<-c(formatfile[formatfile[,3]==Col3[i],-3])
> df<-rbind(df,datavec)
> cat(Col3[i],"\n")
> cat("\\begin{table}","\n")
> cat("\\begin{tabular}{|l|l|l|}","\n")
>          cat("\\hline","\n")
>          #cat (line[1])
>          for (i in 1:nrow(df)){
>     for (j in 1:ncol(df)){
>     cat ("&", paste(df[i,j]), " ")
>     }
>    cat("\\","\\","\n")
> *  cat(paste (("\\"),("\\"),"\n"))*
> }
>          cat("\\hline","\n")
>
>      cat("\\end{tabular}","\n")
> cat("\\end{table}","\n")
>   #print(xtable(df,caption="Phenotype Table",label="tab:summary",
> align="lllllll"),include.rownames=FALSE,width=100)
> }
>
> In the above code, i need to add two backslashes "\\" at the end of each
> table record but if i use cat("///"), i m gettting error message. If i use
> cat("//","//") the backslahes are one space apart . How can i solve my pblm?

cat("\\\\") , actually

Uwe Ligges




> Regards
>
> --
> View this message in context: http://r.789695.n4.nabble.com/Error-while-generating-latex-table-from-sweave-and-R-tp4566954p4566954.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list