How to print (to paper) a nicely-formatted data frame

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()

enter image description here

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.


I would suggest xtable in combination with LaTeX documents. Have a look at the examples in this pdf:

You could also directly combine this with Sweave or knitr.