Is there a way to produce a PDF of a table from R in the same way you produce a plot (ie with pdf() or ggsave())? I realize there are ways with other programs (using sweave
I recently wanted to do this but didn't like the output format of grideExtra
or textplot
so I wrote this function to do it in latex. It's a bit of a hack job and there are better ways with sweave
or knitr
, but you might find it useful to modify for your purposes:
createPDF <- function(xx, name=deparse(substitute(xx))){
require(xtable)
tt <- print(xtable(xx), type='latex')
texfile <- paste0('./reports/', name, '.tex')
cat(
'\\documentclass[12pt]{report}
\\usepackage[landscape]{geometry}
\\date{}
\\begin{document}', tt, '\\end{document}', sep='',
file=texfile
)
## pdflatex from texlive package for linux converts .tex to .pdf
system(paste0('pdflatex ', '-output-directory ./reports ', texfile))
}