2017-03-17 33 views
0

這裏是我的樣本數據集:出口數據幀爲PDF/PNG R中

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) 

我需要將數據幀結果導出爲圖像,如PDF或PNG。我試圖打印它並將其保存爲pdf,但似乎有些列將被刪除。我不知道是否有對數據幀在R.

+4

比什麼更容易?你沒有告訴我們你做了什麼。 –

+0

你可以勾選[這裏](http://stackoverflow.com/questions/23365096/r-save-table-as-image) – akrun

回答

0

導出到圖像的更簡單的方法。如果你要導出爲PNG,你可以這樣做:

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

如果要導出爲PDF格式,你可以這樣做:

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