From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Hendy Subject: Re: Including multiple plots resulting from a loop of R code in LaTeX Date: Sun, 26 Aug 2012 22:15:41 -0500 Message-ID: References: <87wr0p4l0h.fsf@gmx.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Return-path: Received: from eggs.gnu.org ([208.118.235.92]:36053) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T5pnl-0006tI-3f for emacs-orgmode@gnu.org; Sun, 26 Aug 2012 23:15:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T5pni-0000Os-Fm for emacs-orgmode@gnu.org; Sun, 26 Aug 2012 23:15:45 -0400 Received: from mail-qa0-f41.google.com ([209.85.216.41]:33517) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T5pni-0000Ol-BY for emacs-orgmode@gnu.org; Sun, 26 Aug 2012 23:15:42 -0400 Received: by qafk30 with SMTP id k30so1899556qaf.0 for ; Sun, 26 Aug 2012 20:15:42 -0700 (PDT) In-Reply-To: <87wr0p4l0h.fsf@gmx.com> 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.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Eric Schulte Cc: emacs-orgmode On Thu, Aug 23, 2012 at 11:43 AM, Eric Schulte wrote: > John Hendy writes: > >> I'm conducting some neural network analysis, and the results are >> highly dependent on the random seed set prior to creating the model. I >> loop through seeds 1-500, storing the predicted values in one data >> frame and a table of mean sum of squared errors in another table. >> >> Then, I use ggplot to create only the 10 or so plots with the lowest >> error. The loop is something like this: >> >> ---------- >> for(i in 1:10) { >> >> filename <- paste("neuralnet-","-seed-",as.character(mse[i,1]),".pdf", sep="") >> >> pdf(filename, width=12, height=8) >> >> [ggplot code] >> >> dev.off() >> ---------- >> >> What I want to know is how to include the resultant files in LaTeX >> export. Since my model runs and then sorts by error, I don't know >> which seeds produce the best files beforehand, so I'd have to look at >> the error table and manually insert the plot names by hand. Changing >> results means changing file names by hand again. >> >> Any suggestions for things like this where the output of a babel block >> is not a single file? >> > > Have you tried using header arguments like the following. > > :results output raw :exports results > > and then printing the file names (including the Org-mode link syntax) to > STDOUT from within your R code block. Disregard the previous. I found that I should be using cat(paste(...)) instead of print(), since that removes the [1] from each line. Unfortunately, ,--- | cat(paste("[[../plots/",filename,"]]",sep=""), sep="\n\n") `--- still gives me output in orgmode of filenames with no new lines in between so my plots are being printed 4-up on a page (2 wide, 2 tall) instead of only 1 wide and 2 tall. If I manually enter new lines in between the output file names, they behave as they should. How do I get org to accept the extra newlines I'm trying to add? Executing in the R session itself behaves as expected and does space the lines. Thanks, John > > If I understand correctly that should result in the behavior you're > after. > > Best, > >> >> >> Thanks, >> John >> > > -- > Eric Schulte > http://cs.unm.edu/~eschulte