Question

I would like to print a dataframe to a pdf file. I have tried the following:

 pdf("myfile.pdf")
 grid.table(df)
 dev.off()

This actually works, but draws the dataframe with some cell fill colors, and other some formatting, as well as row numbers.

I just want to draw a dataframe with no specific formatting, and especially with no row numbers.

I also need to mention that I want to draw this dataframe along with a plot. (plot above the dataframe). I have tried using:

 layout(matrix(c(1,2), nrow=2, byrow=TRUE), heights = c(2,1))

but the dataframe shows up on top of my plot (please see below)... I am not sure why?

enter image description here

Is there an easy way of doing that?

Thanks!

Was it helpful?

Solution

You can specify where you want your data frame with viewport :

plot(NA, xlim=c(0,2), ylim=c(0,3), bty='n', xaxt='n', yaxt='n', xlab='', ylab='')
print(grid.table(df,show.rownames=F,vp=viewport(x=0.5,y=0.1)))

x and y values are relatives, x=.5,y=.1 place your data.frame in the bottom middle of your plot.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top