# NOT RUN {
Rscript -e 'date()' -e 'format(Sys.time(), "%a %b %d %X %Y")'
# Note that Rscript is not by default in the PATH on Windows, so
# either put it there or use an explicit path to Rscript.
# at the standard Windows command line
Rscript -e "date()" -e "format(Sys.time(), \"%a %b %d %X %Y\")"
# in other shells, e.g. bash or tcsh, prefer
Rscript -e 'date()' -e 'format(Sys.time(), "%a %b %d %X %Y")'
# Get the same initial packages in the same order as default R:
Rscript --default-packages=methods,datasets,utils,grDevices,graphics,stats -e 'sessionInfo()'
## example #! script for a Unix-alike
#! /path/to/Rscript --vanilla --default-packages=utils
args <- commandArgs(TRUE)
res <- try(install.packages(args))
if(inherits(res, "try-error")) q(status=1) else q()
# }
Run the code above in your browser using DataLab