Manish Gupta
2012-Apr-18 07:43 UTC
[R] Error while generating latex table from sweave and R?
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? 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.
Uwe Ligges
2012-Apr-18 10:48 UTC
[R] Error while generating latex table from sweave and R?
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.