I would like to use the toggles from etoolbox
to direct Sweave to evaluate or not evaluate chunks of code. Example:
\newtoggle{FirstTime}
\toggletrue{FirstTime}
%\togglefalse{FirstTime}
\iftoggle{FirstTime}{
<<>
read.csv("My Big Fat Data file.csv") -> MyData
@
}
The idea would be to read in the data at the beginning of the work session and then \togglefalse
so it would not need to be read again. I am using Eclipse and StatET, so object MyData would be resident in memory and accessible to R throughout the session.
However, the above code evaluates regardless of the toggle value.
I know I can achieve this result by changing eval=TRUE
to eval=FALSE
- but using toggles would be cleaner and give more flexibility.
@
. Try adding\makeatletter
before the\iftoggle
and a\makeatother
after the closing}
. You also should have an additional{}
at the end for the case where the\iftoggle
evaluates tofalse
.\ifftoggle
lacks the ‘false’-part.