[Rd] Bug (?) in vignette handling

Duncan Murdoch murdoch@dunc@n @end|ng |rom gm@||@com
Thu Oct 28 19:18:54 CEST 2021


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.

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.



More information about the R-devel mailing list