如何导出(到 word 或 ppt)在 R 中生成的可编辑图形?

How to export (to word or ppt) editable graph generated in R?

我想将生成的图形(通过ggplot2或任何其他包)保存到word或ppt中的可编辑格式中。如何在 R 中执行此操作? 我用过

install.packages("ReporteRs")
install.packages("export")

但显示相同的消息,即

Installing package into ‘C:/Users/ACER/Documents/R/win-library/3.6’
(as ‘lib’ is unspecified)
Warning in install.packages :
  package ‘ReporteRs’ is not available (for R version 3.6.1)


Installing package into ‘C:/Users/ACER/Documents/R/win-library/3.6’
(as ‘lib’ is unspecified)
Warning in install.packages :
  package ‘export’ is not available (for R version 3.6.1)

那么有updated/smoothly工作包吗?

根据 ReporteRs 文档,ReporteRs 包已重命名 officer

要安装...

install.packages("officer") 

您也可以试试 eoffice 包:

install.packages("eoffice")
ggplot(mtcars, aes(mpg, disp, color = factor(cyl))) + geom_point()
topptx(filename = file.path(tempdir(), "mtcars.pptx"))
## or todocx(filename = "mtcars.docx")
p <- ggplot(mtcars, aes(mpg, disp, color = factor(cyl))) + geom_point()
topptx(p, filename = file.path(tempdir(), "mtcars.pptx"), width = 6, height = 4)