每当我运行它时,我会尝试抑制Saving 7 x 7 in image输出ggsave(),但似乎不可能.这可能吗?怎么做?
我尝试了以下,但没有任何作用:
capture.output()sink()最小的"工作"示例:
librrary(ggplot2)
df <- data.frame(gp = factor(rep(letters[1:3], each = 10)),
y = rnorm(30))
plot.to.be.saved <- ggplot(df) + geom_point(aes(x = gp, y = y))
sink('/dev/null')
ggsave(filename = '~/.so.pdf', plot = plot.to.be.saved)
sink()
# Saving 7 x 7 in image
options(warn=-1)
no.output.please <- ggsave(filename = '~/.so.pdf', plot = plot.to.be.saved)
# Saving 7 x 7 in image
capture.output(ggsave(filename = '~/.so.pdf', plot = plot.to.be.saved), file = 'NUL')
# Saving 7 x 7 in image
Run Code Online (Sandbox Code Playgroud)
小智 5
如果您收到如下消息:
保存 6.45 x 7.47 图像
ggsave() 告诉您它渲染图像的大小,因为没有指定大小值。
添加以下内容以ggsave()防止出现此消息:
width=w, height=h
Run Code Online (Sandbox Code Playgroud)