From: tsd@tsdye.com (Thomas S. Dye)
To: John Hendy <jw.hendy@gmail.com>
Cc: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Re: Selective export of Babel code blocks
Date: Mon, 18 Jun 2012 07:11:29 -1000 [thread overview]
Message-ID: <m1fw9sczpa.fsf@tsdye.com> (raw)
In-Reply-To: <CA+M2ft9Ye+ESjgoDZBfufP0_ZpMf9rt1oUbaUrHkT3LfsjaWmw@mail.gmail.com> (John Hendy's message of "Mon, 18 Jun 2012 09:53:57 -0500")
John Hendy <jw.hendy@gmail.com> writes:
> I recently started a paper using Babel in a more full-functioned way
> to display both R code as well as output. Previously I've just used
> the convenience of headings and src blocks to create R plots and have
> the code stored nicely for future reference. I'm exporting via LaTeX
> to create something to promote R and why it's awesome in conjunction
> with org-mode at work, which is a Minitab environment. Thus, I'd like
> to include actual R code to familiarize others. On with the problem.
> I'm also using tikzDevice. Thus, my paper so far is about like so:
>
> ----------
> * Plotting this vs. that
>
> Not we'll plot this vs. that. Here's the R code:
>
> #+begin_src R :exports none
> tikzDevice("file.tex", width=6, height=4, standAlone=T)
> #+end_src
>
> #+begin_src R :exports both
> data <- read.csv("file.csv", header=T)
> sub <- subset(data, output > 5)
> ggplot(sub, aes(x=x, y=y)) + geom_point()
> #+end_src
>
> #+begin_src R :exports none
> dev.off()
> tools::texi2pdf("file.tex")
> #+end_src
> ----------
>
> Anyway, something like this. This isn't a huge poroblem... I'm
> generating a lot of the same type of scatterplot just using different
> variables, so I can copy and yank the blocks and just change
> variable/file names. Doing this got me to thinking how it would be
> quite neat to run code in a block but mark it to be omitted from
> export for these kind of "setup" lines that are necessary for the
> desired graphs but unnecessary for your reader to see over and over
> again.
>
> Thoughts? I'm quite a novice and very possibly missed something that
> can already do this.
>
>
> Thanks!
> John
>
>
Hi John,
One way to do this might be to name the source code block and then use
an #+CALL: line.
#+name: clean-up
#+begin_src R :exports code
dev.off()
tools::texi2pdf("file.tex")
#+end_src
....
#+CALL: clean-up() :exports none
This way, the original code block will be exported and subsequent calls
should not be.
hth,
Tom
--
Thomas S. Dye
http://www.tsdye.com
next prev parent reply other threads:[~2012-06-18 17:11 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-18 14:53 Selective export of Babel code blocks John Hendy
2012-06-18 16:08 ` suvayu ali
2012-06-18 16:50 ` John Hendy
2012-06-18 17:08 ` suvayu ali
2012-06-18 17:37 ` William LÉCHELLE
2012-06-18 17:11 ` Thomas S. Dye [this message]
2012-06-18 17:16 ` suvayu ali
2012-06-18 17:31 ` John Hendy
2012-06-18 18:06 ` Andreas Leha
2012-06-18 19:05 ` Thomas S. Dye
2012-06-19 12:55 ` suvayu ali
2012-06-19 13:36 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m1fw9sczpa.fsf@tsdye.com \
--to=tsd@tsdye.com \
--cc=emacs-orgmode@gnu.org \
--cc=jw.hendy@gmail.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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.