emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: John Hendy <jw.hendy@gmail.com>
To: Eric Schulte <eric.schulte@gmx.com>
Cc: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Re: Including multiple plots resulting from a loop of R code in LaTeX
Date: Mon, 27 Aug 2012 15:16:31 -0500	[thread overview]
Message-ID: <CA+M2ft8Z_65sn7QHfxbti91UObTK5_ASmo53dicSkYvgF+qJYQ@mail.gmail.com> (raw)
In-Reply-To: <CA+M2ft_1pTyes4x1u7-YmJ2UR2TgwW83KJYXwuxhcwdw3F2h5A@mail.gmail.com>

> 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.

Why might this be?


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

  reply	other threads:[~2012-08-27 20:16 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-22 17:41 Including multiple plots resulting from a loop of R code in LaTeX John Hendy
2012-08-23 16:43 ` Eric Schulte
2012-08-27  2:58   ` John Hendy
2012-08-27  3:15   ` John Hendy
2012-08-27  3:24     ` John Hendy
2012-08-27 20:16       ` John Hendy [this message]
2012-08-27 20:40         ` Nick Dokos
2012-08-27 21:40           ` John Hendy
2012-08-27 20:50         ` Eric Schulte
2012-08-27 21:37           ` John Hendy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CA+M2ft8Z_65sn7QHfxbti91UObTK5_ASmo53dicSkYvgF+qJYQ@mail.gmail.com \
    --to=jw.hendy@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=eric.schulte@gmx.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).