Example input data with example output using relative pathway in vignette of R package?
The standard way to refer to a file in a package is:
# gives root package directorysystem.file(package="myPackage") # specific filesystem.file("extdata/InputFiles/exampleData.csv", package="myPackage") # best is to use cross-platform way to write a file path:system.file("extdata", "InputFiles", "exampleData.csv", package="myPackage")
When developing with devtools
, the inst
subdirectory is ignored, so you never need to worry about absolute paths. This should work in a vignette. Note that a vignette, I think, only ever uses the installed version of a package, not the one you may have loaded in your development environment (specifically, devtools::load_all()
does not change the code which is used to build the vignette, you must install()
it first).
Finally, using data()
is a bit old fashioned. Hadley and others recommend using lazy data, so the data appears in the namespace automatically. Try the following in your DESCRIPTION
.
LazyData: trueLazyDataCompression: xz