[R] Sweave and optional document sections
Kyle Covington
kylecovington1 at gmail.com
Wed Jan 25 23:01:25 CET 2017
I was just trying to do this and I think I have a reasonable solution that seems to be working well.
In the main document you can include a chunk with a logical section:
<<optnsa, echo=F, results=tex>>=
if(T){
{sink("/dev/null"); Sweave(’subsection.Rnw'); sink(); }
cat('\\input{subsection.tex}')
}
@
Then you can put your subsection logic into subsection.Rnw, just make sure to remove all of the default latex header stuff, just put in the blocks that you want to process:
This comes from a subsection.
<<ssb1>>=
cat(”I’m in a subsection”)
@
This worked for me
Kyle
More information about the R-help
mailing list