2

I'm trying to tie up the loose ends of a package, and I'm pretty much down to just the vignettes. I have four vignettes in the package. For references we'll call them Vignettes A - D. When I run R CMD check, I get the error

Error: processing vignette 'Vignette A.Rmd' failed with diagnostics:
'what' must be a character string or a function

However, anytime I process Vignette A by using the knit button in R Studio, the document compiles just fine.

So I started playing around and eventually, I found that R CMD check fails anytime I have both Vignettes A and C in the package. But any time I remove either one of those two vignettes, R CMD check passes with no errors.

I haven't any clue where to start on this one. Any ideas on what could be the problem with these two files coexisting in a package?

I'm using R 3.2.0. The package in question is in the development branch at Github

Output from .Rcheck log file

* checking files in 'vignettes' ... OK
* checking examples ... OK
* checking for unstated dependencies in vignettes ... OK
* checking package vignettes in 'inst/doc' ... WARNING
Package vignettes without corresponding PDF/HTML:
   'DecisionNetworks.Rmd'
   'GettingStartedWithHydeNet.Rmd'
   'HydeNetPlots.Rmd'
   'WorkingWithHydeNetObjects.Rmd'

* checking running R code from vignettes ... OK
* checking re-building of vignette outputs ... NOTE
Error in re-building vignettes:
  ...
Loading required package: nnet
Loading required package: rjags
Loading required package: coda
Linked to JAGS 3.4.0
Loaded modules: basemod,bugs
Quitting from lines 173-176 (WorkingWithHydeNetObjects.Rmd) 
Error: processing vignette 'WorkingWithHydeNetObjects.Rmd' failed with diagnostics:
'what' must be a character string or a function
Execution halted
Benjamin
  • 16,897
  • 6
  • 45
  • 65
  • Can't you set up R CMD check to generate an error log? – IRTFM Jun 26 '15 at 21:22
  • Running `R CMD check --help` just now it appears you should already be getting a file in your working directory with extension: `.Rcheck` – IRTFM Jun 26 '15 at 21:31
  • That part hadn't occurred to me yet. I was using `devtools::check`, but that runs `build` before it runs `check`, so I wasn't getting the output because I was never getting to `check`. I'm running `check` from the command line right now. – Benjamin Jun 26 '15 at 21:35
  • But unless there's an option for more detail, it doesn't seem to give me much more to go on. – Benjamin Jun 26 '15 at 21:39
  • Well, it did tell you where to look, didn't it? – IRTFM Jun 26 '15 at 21:45
  • In the R console, use `knitr::knit('vignettes/WorkingWithHydeNetObjects.Rmd')` to knit the vignette, and check `traceback()` when the error occurs. Remember to clean up the auxiliary output files in the package afterwards if there are any. – Yihui Xie Jun 27 '15 at 19:13
  • Thanks, Yihui. That got me there. I'll write up the solution below. – Benjamin Jun 28 '15 at 02:32

1 Answers1

2

Yuhui's hint got me to the solution. At first, I ran knitr::knit('vignettes/WorkingWithHydeNetObjects.Rmd') and everything worked fine. Then I tried running knit on the other vignette with the coexistence problem and found no errors. Then I ran knit on WorkingWithHydeNetObjects.Rmd again, and this time the error was produced.

traceback identified the error as coming from do.call. I was passing a missing argument to do.call when it should have been passing a character string. The behavior of the functions was changed by changing and option in the other vignette.

So the moral of the story is not to assume that each vignette will be built in its own environment. Any options you set in one vignette will be carried over into subsequent vignettes.

Benjamin
  • 16,897
  • 6
  • 45
  • 65