From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Hendy Subject: Re: rmarkdown-like production of multiple plots in org Date: Tue, 31 Mar 2020 15:12:21 -0500 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:49077) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jJNFU-0004BJ-8C for emacs-orgmode@gnu.org; Tue, 31 Mar 2020 16:12:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jJNFS-0002u1-Fb for emacs-orgmode@gnu.org; Tue, 31 Mar 2020 16:12:35 -0400 Received: from mail-vs1-xe34.google.com ([2607:f8b0:4864:20::e34]:45514) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jJNFS-0002sC-B2 for emacs-orgmode@gnu.org; Tue, 31 Mar 2020 16:12:34 -0400 Received: by mail-vs1-xe34.google.com with SMTP id x82so14308511vsc.12 for ; Tue, 31 Mar 2020 13:12:34 -0700 (PDT) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane-mx.org@gnu.org Sender: "Emacs-orgmode" To: Matt Price Cc: Org Mode On Tue, Mar 31, 2020 at 2:22 PM Matt Price wrote: > > I'm completely new to R. > > I've started working with a project that creates plots using the ggplot p= ackage -- so by default it creates grid objects, rather than writing to fil= es. > > In rmarkdown/rstudio, I can write something like this in a SOMEFILE.Rmd : > > ``` > install_github('eeholmes/CoV19') > library(CoV19) > getdata(); > plot4(world, 'Ontario Canada') > plot2(world, 'Italy') > plot4(states, "WA") > ``` > Interesting. I hadn't really thought that approach through. For exploratory analysis, this sounds awesome and I don't think I've ever tried multiple plots in a single chunk in RStudio. Only after seeing Thomas' reply just now did I realize this isn't just plot(), though... where are those functions from? There might be hidden conveniences that don't apply to pure ggplot() calls... dunno. I will add that as soon as you want to start tailoring sizes or how these appear in the resultant file, I think you'd have to split these into separate chunks in order to set the options, no? > 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. In RStudio, runn= ing just that block will also create all three blocks and display them in t= he editor. > > 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! Perhaps an alternative is running all your plots in one block, but using ggsave() (or similar) to save out the files directly (vs. using :output/:file to do it). Then you could have file links in the org file instead of the typical 1:1 match-up of a single block to a single result. I did this once during an effort to optimize a neural network. I had a big loop iterating through parameters, and would programmatically save out one residual plot per combination, e.g. model_var1-value_var2-value_etc.png, I also generated an org-mode section and exported headers for each combination, embedding the corresponding [[./plots/foo.png]] image link within that heading. Exporting to pdf let me page through all my residual plots handily to compare them. Anyway, maybe something helpful in there? John