You can put scripts in exec/
and they will be installed along with your package. If you want to call the script from anywhere I would create a small shell script to do so (say it is called myscript
)
#!/bin/sh
Rscript -e 'source(file = system.file("exec/script.R", package = "mypkg")' $@
Then you can put this in your ~/bin
or somewhere else on your PATH
, and run it regardless of where your R package is installed. Command line arguments will be passed to your package's script by the $@
variable in the shell script, so they can be used by optparse
.