<div dir="ltr">Thanks Chuck and all other respondents. Huh. I'll keep experimenting. I like Chuck'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 <<a href="mailto:ccberry@health.ucsd.edu">ccberry@health.ucsd.edu</a>> 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> > On Mar 31, 2020, at 12:23 PM, Matt Price <<a href="mailto:moptop99@gmail.com" target="_blank">moptop99@gmail.com</a>> wrote:<br> > <br> > I'm completely new to R.<br> > <br> > I'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> > <br> > In rmarkdown/rstudio, I can write something like this in a SOMEFILE.Rmd : <br> > <br> > ```<br> > install_github('eeholmes/CoV19')<br> > library(CoV19)<br> > getdata();<br> > plot4(world, 'Ontario Canada') <br> > plot2(world, 'Italy') <br> > plot4(states, "WA")<br> > ```<br> > <br> > 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="animate"' 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> > In RStudio, running just that block will also create all three blocks and display them in the editor. <br> > <br> > By contrast, creating a series of many plots in org is fairly tedious. I have to name the plot individually & put each function call in its own src block. Is there any way to mimic the behaviour of rmarkdown instead? I odn't understand babel or R enough to really even see how something like that could be implemented, but I'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' 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' arg of knitr::knit, then add links for the png's back to the *.org file. I haven'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>