在之前学习的时候,老师有推荐"export"这个神器可以将图片直接导出至ppt,但是发现3.6及4.0版本的R语言仍然无法使用export。
因此,切换至另外一个叫"eoffice"的package。
安装eoffice
install.packages("eoffice")
报错
ERROR: configuration failed for package ‘magick’Warning in install.packages : installation of package ‘magick’ had non-zero exit statusERROR: dependency ‘magick’ is not available for package ‘eoffice’Warning in install.packages : installation of package ‘eoffice’ had non-zero exit status
查看错误内容是因为没有安装Magick++
Configuration failed to find the Magick++ library. Try installing: - deb: libmagick++-dev (Debian, Ubuntu) - rpm: ImageMagick-c++-devel (Fedora, CentOS, RHEL) - csw: imagemagick_dev (Solaris) - brew imagemagick@6 (MacOS)
按照提示安装libmagick++-dev
sudo apt-get install libmagick++-dev
之后就可以加载
library(eoffice)
保存至ppt可使用topptx
topptx(filename ="mtcars.pptx")
保存至doxc可使用todocx
todocx(filename = "mtcars.docx")
支持多处方式输出图片
p <- ggplot(mtcars, aes(mpg, disp, color = factor(cyl))) + geom_point()topptx(p, filename = "mtcars.pptx"), width = 6, height = 4)
也支持表格从ppt或者word的输出和读取
totable(head(mtcars), filename = "mtcars.pptx")
以及输出多种图片格式
tofigure(p, filename = "mtcars.pdf")
联系客服