Turn Off Caching With (LyX + knitr + R)

325 Views Asked by At

Can anybody help me understand how to turn off caching in LyX/knitr when I submit the following type of function calls to R via knitr:

\Sexpr{rnorm(1, 6, 1.1)}

or in a chunk:

<<echo=FALSE, cache=FALSE>>=
rnorm(1, 6, 1.1)
@

Each time I process the document I just get the exact same value as the first time. I know this must be simple, but it's driving me nuts. Thanks a lot, -Gary

1

There are 1 best solutions below

1
On

Solved. There was a set.seed() call in my .Rprofile. When I remove it, this problem goes away in LyX. It threw me because in an R session, only the first call to rnorm() would be determined by the set.seed(), not subsequent calls to rnorm(), whereas from LyX a new session gets created each time a document is created. Since my example only had one call, I always got the same value. Thanks everybody - especially Yi Hui for making knitr.