1 to.latex <- function(x){
2 gsub("\\\\","\\\\\\\\",latexSN(x))
4 cleanup.tolatex <- function(output) {
5 gsub("\\\\textrm\\{e\\}(-?)0*(\\d+)","$\\\\times 10^{\\1\\2}$",output);
9 table.to.latex <- function(table,
16 toprule=if(useBooktabs) "\\toprule" else "\\hline\\hline",
17 midrule=if(useBooktabs) "\\midrule" else "\\hline",
18 bottomrule=if(useBooktabs) "\\bottomrule" else "\\hline\\hline",...) {
20 header <- c("",colnames(table));
22 cbind(rownames(table),
23 apply(table,c(1,2),function(x){format(x,digits=digits,nsmall=nsmall,scientific=scientific,...)})#format(table,digits=digits,scientific=scientific)
25 coefrows <- 2:NROW(res)
26 res[coefrows,-1] <- sub("(\\*+)","^{\\1}",res[coefrows,-1])
27 res[coefrows,-1] <- sub("([eE])\\+?(-?)0*([0-9]+)","$\\\\times 10^{\\2\\3}$",
30 tabspec <- rep("l",ncol(res))
31 tabspec[-1] <- colspec
32 tabbegin <- paste("\\begin{tabular}{",paste(tabspec,collapse=""),"}",sep="")
33 tabend <- "\\end{tabular}"
34 ans <- c(ans,tabbegin)
38 ans <- c(ans,paste(" & \\multicolumn{1}{c}{",trimws(res[1,j]),"}",sep=""))
42 for(i in 2:NROW(res)) {
44 paste(paste(res[i,],collapse=" & "),"\\\\"))
46 if(length(bottomrule))
47 ans <- c(ans,bottomrule)
49 structure(ans,class="Latex")