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. 
     When using '-e' options be aware of the quoting rules in the shell
     used: see the examples.

     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(), "%a %b %d %X %Y")'

     ## 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()

     ## End(Not run)

