Skip to content

keep.source=T counteracts the expected behaviour of cache=T #40

@hans-ekbrand

Description

@hans-ekbrand

I am not sure whether there is a change in pgfSweave, or a bug in my setup, or if this 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 of chunks that only make calculations.

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, sort of. Objects saved in the global environment will be accessible, but not really read from the cache. The caching-mechanism seems inactivitated altogether. EDIT: the subject-line of this issue perhaps should read something like: "caching mechanism inactivated".

The user should not have to manually fiddle with the eval option of each and every chunk in order to get the benefits of caching.

(The chunk-start-markers does not show up correctly, but I can't seem to fix that, it something with how github deals with mark-up text, I guess. The second chunk should have fig=T).

\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)
@

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

\end{document}

Info on my system:

R version 2.14.1 (2011-12-22)
filehash: Simple key-value database (2.2 2011-07-21)
A Set of Tools for Administering SHared Repositories (0.3-4 2011-07-15)
tikzDevice: A Device for R Graphics Output in PGF/TikZ Format (v0.6.1)
pgfSweave: Using PGF Version 2.10
pgfSweave: Version 1.2.1 - 2011-04-03

Kind regards,

Hans Ekbrand

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions