Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

non-evaluated vignettes with knitr::rmarkdown_notangle

Tags:

r

knitr

The knitr package has relatively recently added new notangle vignette engines, such as knitr::rmarkdown_notangle, that allow disabling of evaluation of vignette chunks. The general process of using knitr for vignettes is described here, while the specific notangle functionality is described in an answer to this question.

My problem is that I can't get this to work. I can get it to pass R CMD build by including the .html output in the vignettes directory (I also put a copy in inst/doc), but I can't get it to pass R CMD check unless I specify --no-build-vignettes, or unless I change the rmarkdown_notangle engine back to rmarkdown.

I have built a trivial package that contains the following vignette (in vignettes/notangle.rmd): it's available here.

<!--
%\VignetteEngine{knitr::rmarkdown_notangle}
%\VignetteIndexEntry{Supplementary Materials}
-->
A silly little vignette.

```{r}
2+2
```

My DESCRIPTION file includes

Suggests:
    knitr,
VignetteBuilder: knitr
BuildVignettes: yes

When I try to run R CMD check I get

* checking re-building of vignette outputs ... NOTE
Error in re-building vignettes:
   ...
Error: processing vignette 'notangle.rmd' failed with diagnostics:
Failed to locate the ‘weave’ output file (by engine ‘knitr::rmarkdown_notangle’) 
   for vignette with name ‘notangle’. The following files exist in directory ‘.’:
   ‘notangle.rmd’

Using r-devel (2014-09-17 r66626), but also happens with 3.1.1.

The workaround (which I would strongly prefer to avoid) is to switch from R code chunks to generic code chunks (opens with triple-backtick, rather than triple-backtick+"r"), which Rmarkdown doesn't process.

I'm sure I'm doing something boneheaded. Any clues?

update: I can get what I need (stop all chunks from being evaluated) by explicitly adding eval=FALSE to the options of every chunk, but I'd still like to know what's going on ...

like image 236
Ben Bolker Avatar asked Nov 04 '14 01:11

Ben Bolker


1 Answers

It is a bug in the current version of knitr, and it has been fixed in the development version 1.7.9, which will (hopefully) be v1.8 on CRAN in the future.

like image 90
Yihui Xie Avatar answered Nov 01 '22 10:11

Yihui Xie