I'm using some R code to import and manipulate a time series. The code takes some minutes to run and, as a result, it generates a relatively small time series.
Now, to prevent typesetting to take an annoying amount of time, I thought I could directly import the final result in R/Sweave but, at the same, I would like people that do not have the saved object to automatically generate it. Something like
\IfFileExists{"data.dat"}{
<<echo=FALSE>>=
## import data ##
@
<<eval=FALSE>>=
## code to generate data ##
@
}
{
<<>>=
## code to generate data ##
@
<<echo=FALSE>>=
## save data in data.dat ##
@
}
The problem is that the Sweave compilation ignores the \IfFileExists
and executes both chunks. Is there a way to prevent Sweave to execute chunk if a particular condition is satisfied (i.e. a file exists) ?