R将表格另存为图像 [英] R save table as image

查看:291
本文介绍了R将表格另存为图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将数据框导出为(png)图像.我已经尝试过使用此代码,但是表格被垂直裁剪.

I would like to export a data frame as a (png) image. I've tried with this code, but the table get clipped vertically.

library(ggplot2)
library(gridExtra)

df <- data.frame(a=1:30, b=1:30)

png("test.png")
p<-tableGrob(df)
grid.arrange(p)
dev.off()

是否有一种方法可以避免这种现象而不必手动设置图像的大小?

Is there a way to avoid this behaviour without having to set manually the size of the image?

推荐答案

您可以通过指定高度和宽度来更改此行为.

You can change this behavior by specifying a height and width.

png("test.png", height=1000, width=200)
p<-tableGrob(df)
grid.arrange(p)
dev.off()

无论如何,将表另存为图片通常不是很有帮助.

Anyway, it is usually not very helpful to save tables as pictures.

这篇关于R将表格另存为图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆