Installing executable scripts with the R package
In most scripting languages (like Ruby, Python, etc.), a package manager (like gem, pip, etc.) can install scripts as executables and link them to the directory specified in the PATH variable (for example, / usr / local / BIN). This turns executable scripts into shell commands that the user can execute autonomously and outside of the programming interface.
I wonder if there is such a possibility in R. Given that R uses standard Makefiles, I guess there must be a way to do it, albeit a non-standard one. I already know that we can read command line arguments in an R script using a packagedocopt
. But is there a way to set the script as executable when installing the package?
It would be great to play a major role in this thread, but one working example from CRAN is enough.
source to share
The short (and very sad) answer is you can't. But read on.
Reasoning: R will only write the contents of a package to its own directory .libPaths()
(or the first one in case multiple are given), or a user-specified directory.
So let's say /usr/local/bin/
just out of reach. This is a legitimate strategy.
It's also pretty sad - I wrote a littler (also a CRAN page ) for this purpose: executable R scripts. And we have dozens of those working to work from cron
. So what should we do? A one-time soft link from the scripts/
package subdirectory containing the script before /usr/local/bin
. When a package is updated, the link is saved as a soft link.
And what am I doing for, for example, all delivery examples with littler and more from other packages. Many of them also use docopt .
source to share