Rscript                package:utils                R Documentation

_S_c_r_i_p_t_i_n_g _F_r_o_n_t-_E_n_d _f_o_r _R

_D_e_s_c_r_i_p_t_i_o_n:

     This is an alternative front end for use in '#!' scripts and other
     scripting applications.

_U_s_a_g_e:

     Rscript [options] [-e expression] file [args]

_A_r_g_u_m_e_n_t_s:

 options: A list of options beginning with '--'.  These can be any of
          the options of the standard R front-end, and also those
          described in the details.

expression: a R expression.

    file: The name of a file containing R commands.  '-' indicates
          'stdin'.

    args: Arguments to be passed to the script in 'file'.

_D_e_t_a_i_l_s:

     'Rscript --help' gives details of usage, and 'Rscript --version'
     gives the version of 'Rscript'.

     Other invocations invoke the R front-end with selected options. 
     This front-end is convenient for writing '#!' scripts since it is
     an executable and takes 'file' directly as an argument.  Options
     '--slave --no-restore' are always supplied: these imply
     '--no-save'.

     _Either_ one or more '-e' options or 'file' should be supplied.

     Additional options accepted (before 'file' or 'args') are

     '--_v_e_r_b_o_s_e' gives details of what 'Rscript' is doing.  Also passed
          on to R.

     '--_d_e_f_a_u_l_t-_p_a_c_k_a_g_e_s=_l_i_s_t' where 'list' is a comma-separated list
          of package names or 'NULL'.  Sets the environment variable
          'R_DEFAULT_PACKAGES' which determines the packages loaded on
          startup.  The default for 'Rscript' omits 'methods' as it
          takes about 60% of the startup time.

     Normally the version of R is determined at installation, but this
     can be overridden by setting the environment variable 'RHOME'.

     'stdin()' refers to the input file, and 'file("stdin")' to the
     'stdin' file stream of the process.

_N_o_t_e:

     'Rscript' is only supported on systems with the 'execv' system
     call.

_E_x_a_m_p_l_e_s:

     ## Not run: 
     Rscript -e 'date()' -e 'format(Sys.time(), "

     ## example #! script

     #! /path/to/Rscript --vanilla --default-packages=utils
     args <- commandArgs(); args <- args[-(1:match("--args", args)]
     res <- try(install.packages(args))
     if(inherits(res, "try-error")) q(status=1) else q()

     ## End(Not run)

