Adam Ryczkowski
Adam Ryczkowski

Reputation: 8064

How to include bash scripts in a package?

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.

Upvotes: 9

Views: 916

Answers (1)

Adam Ryczkowski
Adam Ryczkowski

Reputation: 8064

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!

Upvotes: 7

Related Questions