<div dir="ltr">Thanks Chuck and all other respondents.  Huh. I&#39;ll keep experimenting. I like Chuck&#39;s idea of helper function that pipes theoutput as described but for now, it might actually beeasier to stay with Rmarkdown (!). thanks, Matt<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Apr 2, 2020 at 1:39 PM Berry, Charles &lt;<a href="mailto:ccberry@health.ucsd.edu">ccberry@health.ucsd.edu</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
<br>
&gt; On Mar 31, 2020, at 12:23 PM, Matt Price &lt;<a href="mailto:moptop99@gmail.com" target="_blank">moptop99@gmail.com</a>&gt; wrote:<br>
&gt; <br>
&gt; I&#39;m completely new to R.<br>
&gt; <br>
&gt; I&#39;ve started working with a project that creates plots using the ggplot package -- so by default it creates grid objects, rather than writing to files.  <br>
&gt; <br>
&gt; In rmarkdown/rstudio, I can write something like this in a SOMEFILE.Rmd : <br>
&gt; <br>
&gt; ```<br>
&gt; install_github(&#39;eeholmes/CoV19&#39;)<br>
&gt; library(CoV19)<br>
&gt; getdata();<br>
&gt; plot4(world, &#39;Ontario Canada&#39;) <br>
&gt; plot2(world, &#39;Italy&#39;) <br>
&gt; plot4(states, &quot;WA&quot;)<br>
&gt; ```<br>
&gt; <br>
&gt; I sort of love how the rmarkdown package will just create all 3 of those plots, save them to auto-named files, and render to HTML.<br>
<br>
Actually, this is knitr (which rmarkdown Imports) at work.  There are options as to how knitr will handle multiple plots in a chunk as described in<br>
<br>
<a href="https://yihui.org/knitr/options/#plots" rel="noreferrer" target="_blank">https://yihui.org/knitr/options/#plots</a><br>
<br>
(which include `fig.show=&quot;animate&quot;&#39; to create an animation based on multiple plots!)<br>
<br>
So this applies to various filetypes in addition to *.Rmd (*.Rnw, for one). <br>
<br>
<br>
&gt;  In RStudio, running just that block will also create all three blocks and display them in the editor.  <br>
&gt; <br>
&gt; By contrast, creating a series of many plots in org is fairly tedious.  I have to name the plot individually &amp; put each function call in its own src block. Is there any way to mimic the behaviour of rmarkdown instead? I odn&#39;t understand babel or R enough to really even see how something like that could be implemented, but I&#39;d appreciate some pointers.  Thank you!<br>
<br>
Getting babel to handle this seamlessly would be a significant effort.<br>
<br>
You can use ox-ravel (<a href="https://github.com/chasberry/orgmode-accessories.git" rel="noreferrer" target="_blank">https://github.com/chasberry/orgmode-accessories.git</a>) to export to *.Rmd and then render the result.  However, that does not have the interactivity of `org-babel-execute-src-block&#39; and does not insert the graphics into the *.org file. <br>
<br>
I suppose that a function could be created to narrow to the src block, export it as *.Rmd to a buffer, run that buffer as the `text&#39; arg of knitr::knit, then add links for the png&#39;s back to the *.org file. I haven&#39;t thought much about this - getting this to work in a simple case would not be too hard, but there may be a can of worms that this approach opens.<br>
<br>
HTH,<br>
<br>
Chuck<br>
<br>
<br>
</blockquote></div>