R ReporteRs:编辑现有幻灯片 [英] R ReporteRs: Editing Existing Slides

查看:45
本文介绍了R ReporteRs:编辑现有幻灯片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 pptx 格式的演示文稿,我需要经常用我用 R 脚本生成的图表更新它.我想自动替换图形,而不必在屏幕之间复制和粘贴一大堆.我一直在使用 ReporteRs 包,看起来很有希望,但我无法弄清楚如何简单地替换演示文稿中已有的图表.ReporteRs 上的所有文档都表明您必须添加一张新幻灯片,然后将图表放在该新幻灯片上.有没有办法说,删除幻灯片 7 上的图表并用图表 XXX 替换它?"ReporteRs 是最好的包吗?

I have a presentation in pptx format that I need to update frequently with graphs that I generate with an R script. I would like to automate the replacement of the graphs without having to copy and paste between screens a whole bunch of times. I have been playing with the ReporteRs package and it seems promising but I cannot figure out how to simply replace the graphs that are already in the presentation. All of the documentation on ReporteRs indicates that you have to add a new slide and then place your graphs on that new slide. Is there a way to say, 'delete the graph on slide 7 and replace it with graph XXX?' Is ReporteRs the best package for this?

推荐答案

尝试:

library(DescTools)

# create a new PP instance
pp <- GetNewPP()

# create your plt and insert into pp
barplot(1:5)
pic <- PpPlot(width=10, height=5, pp=pp)

# add a new slide
PpAddSlide()

# new plot on new slide, just to make it difficult to go back
barplot(10:5)
pic2 <- PpPlot(width=10, height=5, pp=pp)


# get a collection of slides
slides <- pp[["ActivePresentation"]][["Slides"]]

# maybe convenient to go back to slide 1
slides$Item(1)$Select()

# get a handle to slide 1
slide1 <- slides$Item(1)

# get handle to any pic on the slide
pic1 <- slide1[["Shapes"]]$Item(1)

# delete it
pic1$Delete()

# create and insert a new one
barplot(rep(1,5), col="red")
PpPlot(width=10, height=5, pp=pp)

这篇关于R ReporteRs:编辑现有幻灯片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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