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: Mon, 27 Aug 2012 16:37:29 -0500 Message-ID: References: <87wr0p4l0h.fsf@gmx.com> <877gskys82.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]:54302) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T6702-0006nT-94 for emacs-orgmode@gnu.org; Mon, 27 Aug 2012 17:37:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T66zy-00070l-Bu for emacs-orgmode@gnu.org; Mon, 27 Aug 2012 17:37:34 -0400 Received: from mail-vb0-f41.google.com ([209.85.212.41]:41369) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T66zy-00070f-6I for emacs-orgmode@gnu.org; Mon, 27 Aug 2012 17:37:30 -0400 Received: by vbkv13 with SMTP id v13so5754644vbk.0 for ; Mon, 27 Aug 2012 14:37:29 -0700 (PDT) In-Reply-To: <877gskys82.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 Mon, Aug 27, 2012 at 3:50 PM, Eric Schulte wrote: > John Hendy writes: > >>> Disregard again... adding multiple newlines with cat() doesn't work, >>> but I had the idea to do: >>> >>> cat(paste("[[../plots/",filename,"]]",sep=""), sep="\n") >>> cat("\n") >>> >>> Works great. I suppose I can use this to add #+attr_latex options as >>> well as captions. Cool stuff. >> >> Getting a bit of odd behavior on LaTeX export. Here's the gist of my >> block below. I've iterated through various model parameters and saved >> the results to filenames based on those parameters. These are stored >> in a vector =filenames=. >> >> #+begin_src R :session model :results output raw :exports results >> >> for(i in 1:nrow(filenames)) { >> >> # insert section header >> cat(paste("*Param1 = ", as.character(params[i, 1]), >> "; Param2 = ", as.character(params[i, 2]),"*", sep="")) >> cat("\n\n") >> cat("#+begin_center") >> cat("\n") >> >> read.csv(filename) >> >> for(j in 1:5) { >> >> ggplot code >> >> pdf(output-filename) >> print(p) >> dev.off() >> >> cat(paste("[[../plots/",output-filename,"]]",sep=""), sep="\n") >> cat("\n") >> >> } # end plotting loop >> >> cat("#+end_center") >> cat("\n\n") >> >> } # end filename cycling loop >> >> #+end_src >> >> I get results like so: >> >> #+RESULTS: >> *Param1 = 4; Param2 = 0.025* >> >> >> #+begin_center >> [[../plots/filename1.pdf]] >> >> [[../plots/filename2.pdf]] >> >> [[../plots/filename3.pdf]] >> >> [[../plots/filename4.pdf]] >> >> [[../plots/filename5.pdf]] >> >> #+end_center >> >> There are six of these sections, however when I do C-c C-c on the >> block and then C-c C-e p to export to LaTeX, I get duplicate sections >> back to back. I have to delete the entire results section and only do >> C-c C-e p with an empty results section to have the duplicate removed. >> > > Try replacing ":results output raw" with ":results output org" > >> >> Why might this be? >> > > Because Babel is not able to remove the old results of "raw" output as > the output has no obvious delimiters. However "org" output should be > wrapped in begin/end_org blocks allowing old output to be cleaned up. > > Best, > That works! Sigh... so much to learn... John >> >> >> John >> >> >>> >>> Thanks! >>> >>>> >>>> >>>> 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 >> > > -- > Eric Schulte > http://cs.unm.edu/~eschulte