3

I have read Hadley guide to vignettes and I can't find any information about this. How are the vignettes build? My problem is that it seems that they are build with the suggested packages attached and loaded.

As far as I could test, if I knit it on the console in Rstudio it uses the same environment as the console.

I digged into devtools::build_vignettes but it seems to depend on tools::buildVignettes which I can't understand and seems like the default used when building a package with R CMD build.

This is related to my efforts to solve this question

llrs
  • 3,308
  • 35
  • 68
  • It depends a bit on the vignette builder selected (usually knitr these days), but yes. It's essentially the same as knitting an RMarkdown document; if you don't put in your `library` calls, it's going to record a bunch of errors. – alistaire Feb 27 '18 at 22:50
  • Yes, I am using knitr in my packages, and I put my library calls in my vignette code, but that's not the point of the questions – llrs Feb 28 '18 at 08:31
  • Yes, when you `knit` on the console, it knits in your current environment by default. If you want `knit` in the console to use a new environment, you can give it `envir = new.env()` - see `?knit` for more details. If you use the `knit` button in the RStudio GUI, it actually calls `rmarkdown::render` and executes in a separate environment. You can find a couple questions related to that on this site if you search. – Gregor Thomas Feb 28 '18 at 15:51
  • My question is about how are knit the vignettes when building a package. Perhaps I need to clarify further the question. What made you think I was interested in knit evaluation? Perhaps your comment is related to the other linked question... – llrs Feb 28 '18 at 16:06

1 Answers1

0

When building the package the environment for all the vignettes is shared. So if vignette V1 loads package A, B and C, it will be already loaded for vignette V2 if V2 is build before V1.

That was what I learn from Martin Morgan at Bioconductor mailing list. I couldn't find any other document explaining it.

llrs
  • 3,308
  • 35
  • 68