如何在 Rmarkdown 中保存绘图?

问题描述 投票:0回答:1

我目前正在开发一个项目,我需要从 RMarkdown 中提取 png,我尝试使用 ggsave 但它返回一个关于 $ 的错误,但我没有在提示中使用它们。

我现在尝试过这个:

chene_cor = cor(Chene_num)
chene_cor
sauve = corrplot(chene_cor)
ggsave(filename = "corrplotchene", plot = "sauve", device = "svg")

当我运行此代码时,出现此错误:

Error in x$theme : $ operator is invalid for atomic vectors

关于如何解决这个问题有什么想法吗?如果没有,还有其他想法可以在 Rmd 中保存绘图吗?

谢谢!

r ggplot2 plot r-markdown save
1个回答
0
投票

快跑吧

ggsave(filename = "corrplotchene", device = "svg")

ggsave()
自动获取并保存最后一个图。

© www.soinside.com 2019 - 2024. All rights reserved.