From mtmorgan at fhcrc.org  Sat Apr  5 20:24:47 2014
From: mtmorgan at fhcrc.org (Martin Morgan)
Date: Sat, 05 Apr 2014 11:24:47 -0700
Subject: [Rd] Package vignettes share the same environment?
Message-ID: <53404A6F.70302@fhcrc.org>

In a package 'vig' R CMD build vig (or tools::buildVignettes(dir="vig") with

$ cat vig/vignettes/vig1.Rnw
\documentclass{article}
\begin{document}
<<>>=
x <- 1
@
\end{document}

$ cat vig/vignettes/vig2.Rnw
\documentclass{article}
\begin{document}
<<>>=
x
@
\end{document}

produces vig2.pdf where x is defined with value 1 -- the vignettes share a build 
environment. This seems undesirable in terms of reproducibility (a reader of 
vig2.pdf will not understand where x is assigned; similarly for the results of 
require()  or data() in vig1 referenced in vig2), and is not (?) documented. A 
more elaborate context is

     https://stat.ethz.ch/pipermail/bioc-devel/2014-April/005501.html

Would it be better to build each vignette in its own environment?

$ R --version|head -n 3
R version 3.1.0 RC (2014-04-05 r65379) -- "Spring Dance"
Copyright (C) 2014 The R Foundation for Statistical Computing
Platform: x86_64-unknown-linux-gnu (64-bit)

Martin
-- 
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M1 B861
Phone: (206) 667-2793



[Rd] Package vignettes share the same environment?
Martin Morgan