可以在rmarkDown的PowerPoint中渲染循环
我有几个产生图形的块循环。我想从其中进行PowerPoint演示文稿,但是循环不起作用。它仅渲染第一个图。
这是一个最小的工作示例:
---
title: "Title"
author: John Doe
date:
output:
powerpoint_presentation
---
knitr::opts_chunk$set(echo = FALSE, warning=FALSE)
n <- 7
for(i in 1:n){plot(c(1:i))}
我发现Knitr :: opts_chunk指令会产生冲突。如果没有编织/块规格,它确实会呈现循环。问题是我需要echo = false,因为否则它将呈现许多代码以及图形,
有人知道如何回声= false(或其他块选项)可以通过渲染循环“共存”?
我不介意在HTML上渲染它,但它也避开了其他问题,类似于(带有TabSet)
编辑:我在最后一句话中不清楚。如果渲染到HTML,则循环工作正常,但是在这种情况下,我需要每个循环的图表都在其他选项卡中,并且我不知道该怎么做。同样,PowerPoint使我更容易进一步格式化。
此致。
I have in several chunks loops that produce graphs. I want to make a powerpoint presentation out of them, but the loop doesn't work. It only renders the first graph.
Here is a minimal working example:
---
title: "Title"
author: John Doe
date:
output:
powerpoint_presentation
---
knitr::opts_chunk$set(echo = FALSE, warning=FALSE)
n <- 7
for(i in 1:n){plot(c(1:i))}
I have discovered that the knitr::opts_chunk instructions produces the conflict. If there are no knitr/chunk specifications, it does render the loops. The issue is that I need echo = false, because otherwise it renders many code along with the graphs
Does anyone know how could echo = false (or other chunk options) could "coexist" with rendering loops?
I wouldn't mind rendering it on html but it gaves me other issues as well, similar to this (with tabset)
EDIT: I wasn't clear in the last sentence. If rendered to html, the loops work just fine, but in that case I would need each graph of the loop to be in a different tab, and I have no clue how to do that. Also, powerpoint makes it easier for me for further formatting.
Best regards.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定您是否在这里打电话给孩子.RMD文档,但这是我对这种事情的方法。对于这种方法,您将在运行循环的parent .RMD文件中有一个编码块。该块的结果选项必须设置为:
然后,在该块内,这就是我打电话给我的孩子.rmd文件的地方。一个潜在的麻烦点是,孩子.rmd file 不能 任何名为块的,或者由于重复的块名称而尝试编织时会出现错误。也许有办法解决这个问题,但我还没有开始工作。
父级文件块的一个示例
这是我的 标题,作者等。
特别是询问了PowerPoint幻灯片,但对于Word文件来说,这也是如此。
I'm not sure if you're calling a child .Rmd document here, but that's my approach for this sort of thing. For that approach, you would have one coding chunk in the parent .Rmd file that runs the loop. The results option for that chunk must be set to:
Then, inside that chunk, that's where I call on my child .Rmd file. One potential trouble spot there is that the child .Rmd file cannot have any named chunks or you'll get errors when you try to knit because of replicate chunk names. Maybe there's a way around that, but I haven't gotten it to work.
Here's an example of what my parent .Rmd file chunk looks like where it runs the loop:
And then the file "IndividualSlides.Rmd" is set up like a regular rmarkdown file except that you don't have that heading at the top with the title, author, etc.
You asked about PowerPoint slides, specifically, but this works the same way for Word files.