-1

I need to distribute my code as R package in order to publish a paper. The script is supposed to run in batch mode with keyword argument

e.g.

Rscript script.R --input=foo.txt --barparameter=bar --outputname=output.txt  

It's pretty well written with built-in help function and stuff.

I followed the instruction on how to create R package and things are going fine. However, my script is supposed to be used as the whole script, not its individual function. So far, all R package that I know will provide only the function. I don't know what I suppose to put in ./R directory of R package in this case. Any recommendations would be appreciated.

Aacini
  • 65,180
  • 12
  • 72
  • 108
Victor
  • 13
  • 1

1 Answers1

2

Unfortunately, you will need to change your initial script into distinct functions (or just create one large function). All help files must be written as .rd's.

Next, you will need to create a second script that calls the functions written within the package. This script should be placed in the packages /inst folder or should be embedded within a vignette and placed in the /vignette directory.

coatless
  • 20,011
  • 13
  • 69
  • 84
  • Could you clarify a little bit why I need to create second script that call the first script? Do you mean that the second script should do the work that comparable to my current version, but call function from first script instead? I create the package using R studio and vingette and inst do not seem to be there. I got just DESCRIPTION, R, NAMESPACE, man, and Rproj. What is your choice of program that you create the R package? – Victor May 10 '16 at 21:43
  • The first script must be in function form (e.g. `do_this = function(x){print(x)}`) within the package. The second script can be a working example of how to run the different functions (including batch mode). To use a vignette type: `devtools::use_vignette("my-vignette")` This should auto create the `/vignette` directory. – coatless May 10 '16 at 21:57