Message-ID: <23215.41433.678856.270841@rob.eddelbuettel.com>
Date: 2018-03-19T11:41:13Z
From: Dirk Eddelbuettel
Subject: [R-pkg-devel] Avoid reprocessing Rmd vignette
In-Reply-To: <CANnL8go=F3OdMrrUCUF2_5ZQ_vi0i0PD6RM6bNUWtobnRQ0vJQ@mail.gmail.com>
On 18 March 2018 at 21:57, Tim Keitt wrote:
| That's a great idea, however my problem is with building a vignette, not
| running tests, unless they are linked in some way I'm not understanding.
Similar idea applies: condition, just as Inaki and Thierry suggested. An
example for a conditional vignette evaluation is
```{r echo = FALSE, message = FALSE}`r ''`
hasData <- requireNamespace("hurricaneexposuredata", quietly = TRUE) #1
if (!hasData) { #2
knitr::opts_chunk$set(eval = FALSE) #3
msg <- paste("Note: Examples in this vignette require that the",
"`hurricaneexposuredata` package be installed. The system",
"currently running this vignette does not have that package",
"installed, so code examples will not be evaluated.")
msg <- paste(strwrap(msg), collapse="\n")
message(msg) #4
}
```
and the paper (https://journal.r-project.org/archive/2017/RJ-2017-026/) by
Brooke Anderson and myself discusses #1 to #4.
Dirk
--
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org