[R] Sweave-LaTEX question
Dieter Menne
dieter.menne at menne-biomed.de
Sun Oct 12 11:24:28 CEST 2008
cls59 <sharpsteen <at> mac.com> writes:
> The final piece is a good TeX-aware editor, for windows I prefer WinEdt:
I would like to add Tinn-R.
> However, if you are running something like an optimization
> routine which takes five minutes, you will be waiting five minutes every
> time you typeset the document.
Package cacheSweave provides a nice way around this. However, I prefer the
semi-manual way: Results of long computation are stored in an RData file, which
I delete when I want a recomp. Then use something like:
# if file x.rdata exist, sources x.r; otherwise, loads x.rdata
loadcache = function (x) {
rda1 = strsplit(x,"/")[[1]]
rda1 = paste(rda1[length(rda1)],".rdata",sep="")
if ( !file.exists(rda1))
source(paste(x,".r",sep=""))
if ( !file.exists(rda1)) {
stop("File", rda," could not be created")
}
load(rda1, .GlobalEnv)
}
Dieter
More information about the R-help
mailing list