I need to include several bash scripts in the R package I'm writing. I'd love to distribute them together with the package, so when a user installs the package via devtools::install_github(...)
he/she gets the scripts as well.
I know it is possible, but I don't know how. Including the files in the scripts
subdirectory doesn't seem to suffice. I need a means to tell R (or RStudio) to include them.
I use RStudio for development, so I would appreciate a solution that integrates with the "Build package" functionality that RStudio provides.
bash [filename] runs the commands saved in a file. $@ refers to all of a shell script's command-line arguments. $1 , $2 , etc., refer to the first command-line argument, the second command-line argument, etc.
A bash shell script have parameters. These parameters start from $1 to $9. When we pass arguments into the command line interface, a positional parameter is assigned to these arguments through the shell. The first argument is assigned as $1, second argument is assigned as $2 and so on...
Simply add whatever you want to the inst/xxx
folder in your package.
The folder will get installed as xxx
when you compile/publish the package as a library.
You access the files via system.file()
, e.g.
system.file('scripts/peak_mem.sh', package='clustertools')
See more details on the R packages by Hadley Wickham
Thank you @Axeman!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With