I'd like to print nicely-formatted data frames to paper, ideally from within a script. (I am trying to collect data using an instrument and automatically process and print it using an R script).
Right now I can write a data frame to a text file using
Here is a quick and easy possibility using
grid.table from the gridExtra package:
library(gridExtra) pdf("data_output.pdf", height=11, width=8.5) grid.table(mtcars) dev.off()
If your data doesn't fit on the page, you can reduce the text size
grid.table(mtcars, gp=gpar(fontsize=8)). This may not be very flexible, nor easy to generalize or automate.