[Rd] Example input data with example output using relative pathway in vignette of R package?

Luck Buttered luckbuttered at gmail.com
Sat Oct 31 21:14:06 CET 2015

I'm putting together an R package. I would like to show example code in the
vignette, where example data files (included in the package) are used to
generate an (example) output file.

I read about using example data in Hadley Wickham's post (
http://r-pkgs.had.co.nz/data.html), and believe I should keep my example
data as raw data, as it must be parsed to generate the output.

So, I created a directory in my package structure


with subdirectories InputFiles and OutputFiles.

And I put the example file (exampleData.csv) inside of the InputFiles
subdirectory (/Users/userName/myPackage/inst/extdata/InputFiles).

My vignette is located in:


It contains the following syntax:

fileString = "/Users/userName/myPackage/inst/extdata/InputFiles/exampleData.csv"
doFunction3(fileString, output

I am having two problems with developing this vignette and its example

1) I am unsure if my use of the extdata file is appropriate. This seemed to
be the best directory name and location to place my example files,
according to the aforementioned Hadley Wickham reference.

2) I am unsure how to make the pathways relative, instead of absolute, as I
have them currently. This example code does not run automatically, as you
can see. Instead, I have it under an R chunk of eval=FALSE so that it is
simply listed there for the users to test themselves. After running the
example code, the users can also check that the output file was indeed
created in (/Users/userName/myPackage/inst/extdata/OutputFiles). What is
the best way for me to allow the user to not have to use an absolute path
when following the example? Is it possible to just follow a relative path
from within the package directory myPackage? I cannot create a help manual
(AFAIK) because this example code is not just an example of running one
function; instead, it is an example of running several functions and then
viewing the output.

If it would make more sense for me to just run the R chunk with eval=TRUE,
I would have the same question: How could I get it to automatically run
with just relative pathways?

Thank you for any advice!

	[[alternative HTML version deleted]]

More information about the R-devel mailing list