cameronbracken/pgfSweave — Issue #40: eval=T counteracts the expected behaviour of cache=T
Author: hans-ekbrand
Created: 2012-03-08 20:57:18+00:00
State: open

I am not sure whether there is a change in pgfSweave, or a bug in my setup, or if these is how things have worked all along, but I recently found out that I had to manually set eval=F in order to get the expected benefits from caching.

Below is a minimal reproducible example. I would expect it to run significantly faster the second time, since the calculations of the first chunk should be omitted and the results loaded from the cache. However, the first chunk is run again, unless I manually sets eval=F. Doing so, I can get the expected behaviour.

\documentclass{article}
\usepackage{tikz}
\usepackage[utf8]{inputenc}
\usepackage[nogin]{Sweave}
\SweaveOpts{echo=F,fig=F,eval=T,results=hide,cache=T,width=4,height=4,external=T}
\begin{document}

<>=
x <- 10000
set.seed(42)
a <- rnorm(x)
b <- factor(LETTERS[sample(1:7, x, replace = TRUE)])
c <- factor(LETTERS[sample(1:4, x, replace = TRUE)])
my.fit <- glm(c ~ b + a, family = "binomial")
my.results <- confint(my.fit)
@

<>=
barplot(rowSums(my.results[2:7,]))
@

\end{document}

Kind regards,

Hans Ekbrand