[R] Sweave and optional document sections

Gabor Grothendieck ggrothendieck at gmail.com
Fri Mar 5 19:12:17 CET 2010

Its possible to do that using latex if/then/else macros which you can
find in latex package ifthen; however, once you are getting to that
level of complexity, Sweave is more of a hindrence than a help and is
probably no longer the appropriate tool for the job.

On Fri, Mar 5, 2010 at 12:55 PM, Aleksey Naumov <anaumov at gmail.com> wrote:
> Dear R and Sweave users,
> Is there a way to have optional sections in a Sweave-generated report
> document, complete with section header(s), text and code chunks? In other
> words, I'd like for my report to include or omit certain sections based on
> the data itself.
> For example, If I examine the input dataset early on in the report and set a
> variable has_daily_data = TRUE, then I'd like to have a section that looks
> at the daily data in detail, with subsections, text and code chunks. What
> facilities do I have in Sweave (or odfWeave) for that?
> Perhaps, for code chunks, I could wrap all the code inside in
> if(has_daily_data) {...}? What about inserting conditional text and
> sections? Would it make sense to split the document into subdocuments and
> somehow include the optional subdocuments only if needed? How would I go
> about that?
> Would appreciate any pointers. Thank you,
> Aleksey
>        [[alternative HTML version deleted]]
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list