I am trying to write a vignette for a package in R. I followed the training course from Vanderbilt University , as well as the official documentation .
I created a .Rnw
Sweave file and placed it in the inst/doc
subdirectory inside my package. Inside the same inst/doc
subdirectory, I put the example
folder containing some example text files. My package has the function myparser(path)
, which I want to demonstrate in a vignette; myparser(path)
creates several frames of data by reading in text files inside a folder with an absolute path name path
.
Then I checked the package using R CMD CHECK
and got this error:
* checking running R code from vignettes ... 'mypackage-vignette.Rnw' using 'UTF-8' ... failed ERROR Errors in running code in vignettes: when running code in 'mypackage-vignette.Rnw' ... > library(mypackage) Loading required package: ggplot2 > myparser("/example/") Warning in file(file, "rt") : cannot open file '/example/': No such file or directory When sourcing 'mypackage-vignette.R': Error: cannot open the connection Execution halted
I see that my attempt to use the relative path to the folder did not work (probably should have been obvious to me), but I'm still not sure how to fix this situation. I do not want to replace path
with the absolute path to the folder on my computer, because then the vignette code will not play on other people's computers.
How to include example files in a package so that the vignette code is reproducible? Am I even right about this problem?
(Sorry, this question is no longer reproducible!)
source share