Skip to content

Instantly share code, notes, and snippets.

@talegari
Last active March 19, 2019 00:34
Show Gist options
  • Save talegari/ab406f5405504ca02aaaf2e1cdf6f9e1 to your computer and use it in GitHub Desktop.
Save talegari/ab406f5405504ca02aaaf2e1cdf6f9e1 to your computer and use it in GitHub Desktop.
Instructions to make a R script/program executable on *nix machines
-------------------------------------------------------------------
Instructions to make a R script/program executable on *nix machines
-------------------------------------------------------------------
Author: Srikanth KS
Date : 12th February 2018
- We assume that R, Rscript and required R packages are installed.
- 'Rscript' is a program to execute scripts/programs written in R language.
- Add this shebang(without quotes) as the first line of the script: '#!/usr/bin/env Rscript'.
- '.R' extension for the R script is not mandatory. Lets say the R script is 'myscript'.
- Make your script executable by: 'sudo chmod u+x myscript'.
- Move your script to '/usr/local/bin': 'sudo mv myscript /usr/local/bin'
- Now 'myscript' is callable from terminal.
- Suggestion: Use a package like 'docopt', 'optparse' etc to create a friendly interface for your script.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment