Skip to content

Instantly share code, notes, and snippets.

@drewhendrickson
Last active August 29, 2015 13:59
Show Gist options
  • Select an option

  • Save drewhendrickson/10690861 to your computer and use it in GitHub Desktop.

Select an option

Save drewhendrickson/10690861 to your computer and use it in GitHub Desktop.
```
$ Rscript --vanilla R/myscript.R 12 &> logs/myscript.log &
```
Rscript runs the .R file as a standalone script, without going into the R environment.
The –vanilla flag means that you run the script without calling in your .Rprofile
(which is typically set up for interactive use) and without prompting you to save a workspace image.
I always run the Rscript from the save level to that which is set as the project root for Rstudio
to avoid any problems because of relative paths being set up wrongly.
The number after the .R file to be run is the number of cores you want to run the parallel stuff on.
Other arguments you may want to pass to R would also go here.
the &> operator redirects both the stdin and stderror to the file logs/myscript.log
(I always set up a logs directory in my R projects for this purpose).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment