From luckbuttered at gmail.com  Sat Oct 31 21:14:06 2015
From: luckbuttered at gmail.com (Luck Buttered)
Date: Sat, 31 Oct 2015 15:14:06 -0500
Subject: [Rd] Example input data with example output using relative pathway
 in vignette of R package?
Message-ID: <CAGRPoRSBs2-dc=KhqDrOA4fK8U0oHF89LY2=gF9rPE9shqOYag@mail.gmail.com>

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

/Users/userName/myPackage/inst/extdata/

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:

/Users/userName/myPackage/vignettes/myPackage.Rnw

It contains the following syntax:

<<eval=FALSE>>=
fileString = "/Users/userName/myPackage/inst/extdata/InputFiles/exampleData.csv"
doFunction1(fileString)
doFunction2(fileString)
doFunction3(fileString, output
="Users/userName/myPackage/inst/extdata/OutputFiles")@

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

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]]



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