[R] KnitR/RMarkdown: Is there a way to not print a section of the document?

Yihui Xie xie at yihui.name
Tue Jan 28 03:46:11 CET 2014


Similarly, you can split a large input document into child documents
in knitr, e.g.

<<chap1, child="chap1.Rnw">>=
@

You can comment out this chunk when you do not need it. Or control it
programmatically,

<<setup, include=FALSE>>=
include_me = TRUE  # or FALSE
@

....

<<chap1, child=if (include_me) "chap1.Rnw">>=
@

Regards,
Yihui
--
Yihui Xie <xieyihui at gmail.com>
Web: http://yihui.name


On Mon, Jan 27, 2014 at 8:20 PM, Duncan Mackay <dulcalma at bigpond.com> wrote:
> Hi
>
> I use Sweave and have a master Rnw file and parent files.
> If there are large chunks I split them up and then just put a % in front of
> the \SweaveInput if unwanted.
>
> Otherwise I split up the tex files with \input and \includeonly
>
> You could get into the chunk options and change things there but that is
> fiddly if you want to reuse
>
> Regards
>
> Duncan
>
> Duncan Mackay
> Department of Agronomy and Soil Science
> University of New England
> Armidale NSW 2351
> Email: home: mackay at northnet.com.au
>
>
>
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
> Behalf Of Jeff Johnson
> Sent: Tuesday, 28 January 2014 10:49
> To: R help
> Subject: [R] KnitR/RMarkdown: Is there a way to not print a section of the
> document?
>
> I've been looking through the R documents to see if there's a way to not
> output certain chunks of code. I'm trying to present a document to a team
> of folks that won't necessarily be interested in the line-by-line code,
> though they are interested in the charts, etc. Thus, I'd like to not output
> certain chunks of code. Is there a way to suppress sections?
>
> Thank you.
>
> --
> Jeff




More information about the R-help mailing list