将数据框导出到R中的pdf / png [英] Export dataframe to pdf/png in R
本文介绍了将数据框导出到R中的pdf / png的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的示例数据集:
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中的图像。
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.
推荐答案
如果要导出为png,您可以这样做:
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()
如果要导出为pdf,则可以这样操作:
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()
这篇关于将数据框导出到R中的pdf / png的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文