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

Manish Gupta mandecent.gupta at gmail.com
Wed Apr 18 09:43:11 CEST 2012


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.



More information about the R-help mailing list