Rev 64434 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
% File src/library/utils/man/Rscript.Rd% Part of the R package, http://www.R-project.org% Copyright 1995-2013 R Core Team% Distributed under GPL 2 or later\name{Rscript}\alias{Rscript}\title{Scripting Front-End for R}\description{This is an alternative front end for use in \samp{#!} scripts andother scripting applications.}\usage{\special{Rscript [options] [-e expr [-e expr2 ...] | file] [args]}}\arguments{\item{options}{a list of options, all beginning with \samp{--}. Thesecan be any of the options of the standard \R front-end, and also thosedescribed in the details.}\item{expr, expr2}{\R expression(s), properly quoted.}\item{file}{the name of a file containing \R commands. \samp{-}indicates \file{stdin}.}\item{args}{arguments to be passed to the script in \code{file}.}}\details{\command{Rscript --help} gives details of usage, and\command{Rscript --version} gives the version of \command{Rscript}.Other invocations invoke the \R front-end with selected options. Thisfront-end is convenient for writing \samp{#!} scripts since it is anexecutable and takes \code{file} directly as an argument. Options\option{--slave --no-restore} are always supplied: these imply\option{--no-save}. (The standard Windows command line has no conceptof \samp{#!} scripts, but Cygwin shells do.)\emph{Either} one or more \option{-e} options or \code{file} shouldbe supplied. When using \option{-e} options be aware of the quotingrules in the shell used: see the examples.Additional options accepted (before \code{file} or \code{args}) are\describe{\item{\option{--verbose}}{gives details of what \command{Rscript} isdoing. Also passed on to \R.}\item{\option{--default-packages=list}}{where \code{list} is acomma-separated list of package names or \code{NULL}. Sets theenvironment variable \env{R_DEFAULT_PACKAGES} which determines thepackages loaded on startup. The default for \command{Rscript}omits \pkg{methods} as it takes about 60\% of the startup time.}}Spaces are allowed in \code{expression} and \code{file} (but will needto be protected from the shell in use, if any, for example byenclosing the argument in quotes).#ifdef unixNormally the version of \R is determined at installation, but this canbe overridden by setting the environment variable \env{RHOME}.#endif#ifdef windowsThe \R files are found from the location of the \file{Rscript.exe}executable. If this is copied elsewhere, the environment variable\env{RHOME} should be set to the top directory of the \R installation.Unlike Unix-alikes, this links directly to \file{R.dll} rather thanrunning a separate process.#endif\code{\link{stdin}()} refers to the input file, and\code{\link{file}("stdin")} to the \code{stdin} file stream of theprocess.}#ifdef unix\note{\command{Rscript} is only supported on systems with the \code{execv}system call.}#endif\examples{\dontrun{#ifdef unixRscript -e 'date()' -e 'format(Sys.time(), "\%a \%b \%d \%X \%Y")'#endif#ifdef windows# 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 lineRscript -e "date()" -e "format(Sys.time(), \\"\%a \%b \%d \%X \%Y\\")"# in other shells, e.g. bash or tcsh, preferRscript -e 'date()' -e 'format(Sys.time(), "\%a \%b \%d \%X \%Y")'#endif## example #! script for a Unix-alike#! /path/to/Rscript --vanilla --default-packages=utilsargs <- commandArgs(TRUE)res <- try(install.packages(args))if(inherits(res, "try-error")) q(status=1) else q()}}\keyword{utilities}