3

Here is my sample dataset:

Singer <- c("A","B","C","A","B","C")
Rank <- c(1,2,3,3,2,1)
Episode <- c(1,1,1,2,2,2)
Votes <- c(0.3,0.28,0.11,0.14,0.29,0.38)

Result <- data_frame(Episode,Singer,Rank,Votes)

I need to export the dataframe Result to image such as pdf or png. I tried to print it and save it to pdf, but it seems some of the columns would be deleted. I wonder if there is a easier way to export dataframe to image in R.

Ran Tao
  • 311
  • 1
  • 4
  • 13

1 Answers1

9

If you want to export as a png, you can do like this:

library(gridExtra)
png("test.png", height = 50*nrow(df), width = 200*ncol(df))
grid.table(df)
dev.off()

If you want to export as a pdf, you can do like this:

library(gridExtra)
pdf("test.pdf", height=11, width=10)
grid.table(df)
dev.off()
Ning
  • 514
  • 5
  • 5