[Rd] Bug (?) in vignette handling
Martin Maechler
m@ech|er @end|ng |rom @t@t@m@th@ethz@ch
Fri Oct 29 11:52:18 CEST 2021
>>>>> Duncan Murdoch
>>>>> on Thu, 28 Oct 2021 13:18:54 -0400 writes:
> This StackOverflow post: https://stackoverflow.com/q/69756236/2554330
> points out that objects created in one vignette are available in a later
> vignette. I don't think this should be happening: vignettes should be
> self-contained.
I strongly agree.
> The current answer there, https://stackoverflow.com/a/69758025/2554330,
> suggests that "R CMD check" will detect this. However, sometimes one
> vignette can replace a standard function with a custom version, and then
> both will work without generating an error, but the second vignette
> won't do the same thing if run independently.
> For example, try these pure Sweave vignettes:
> -------------------------
> aaa3.Rnw:
> -------------------------
> \documentclass{article}
> %\VignetteIndexEntry{Sweave aaa3}
> \begin{document}
> <<>>=
> mean <- function(x) "I am the Sweave mean"
> @
> \end{document}
> ------------------------
> aaa4.Rnw:
> ------------------------
> \documentclass{article}
> %\VignetteIndexEntry{Sweave aaa4}
> \begin{document}
> <<>>=
> mean(1:5)
> @
> \end{document}
> Put these in a package, build and install the package, and you'll see
> that the mean() function in aaa4.Rnw prints the result from the
> redefined mean in aaa3.Rnw.
Is it because R is *not* run with --no-save --no-restore
accidentally?
Without looking, I would not expect that the vignettes are run
inside the same running R (even though that may speedup things)
More information about the R-devel
mailing list