options                 package:base                 R Documentation

_O_p_t_i_o_n_s _S_e_t_t_i_n_g_s

_D_e_s_c_r_i_p_t_i_o_n:

     Allow the user to set and examine a variety of global _options_
     which affect the way in which R computes and displays its results.

_U_s_a_g_e:

     options(...)

     getOption(x)

     .Options

_A_r_g_u_m_e_n_t_s:

     ...: any options can be defined, using 'name = value' or by
          passing a list of such tagged values.  However, only the ones
          below are used in base R. Further, 'options('name') ==
          options()['name']', see the example. 

       x: a character string holding an option name.

_D_e_t_a_i_l_s:

     Invoking 'options()' with no arguments returns a list with the
     current values of the options.  Note that not all options listed
     below are set initially.  To access the value of a single option,
     one should use 'getOption("width")', e.g., rather than
     'options("width")' which is a _list_ of length one.

     '.Options' also always contains the 'options()' list (as a
     pairlist, unsorted), for S compatibility.  Assigning to it will
     make a local copy and not change the original.

_V_a_l_u_e:

     For 'getOption', the current value set for option 'x', or 'NULL'
     if the option is unset.

     For 'options()', a list of all set options sorted by name.  For
     'options(name)', a list of length one containing the set value, or
     'NULL' if it is unset.  For uses setting one or more options, a
     list with the previous values of the options changed (returned
     invisibly).

_O_p_t_i_o_n_s _u_s_e_d _i_n _b_a_s_e _R:


     '_a_d_d._s_m_o_o_t_h': typically logical, defaulting to 'TRUE'.  Could also
          be set to an integer for specifying how many (simulated)
          smooths should be added.  This is currently only used by
          'plot.lm'.

     '_c_h_e_c_k._b_o_u_n_d_s': logical, defaulting to 'FALSE'.  If true, a
          warning is produced whenever a vector (atomic or 'list') is
          extended, by something like 'x <- 1:3; x[5] <- 6'.

     '_c_o_n_t_i_n_u_e': a non-empty string setting the prompt used for lines
          which continue over one line.

     '_d_e_f_a_u_l_t_P_a_c_k_a_g_e_s': the packages that are attached by default when
          R starts up.  Initially set from value of the environment
          variable 'R_DEFAULT_PACKAGES', or if that is unset to
          'c("datasets", "utils", "grDevices", "graphics", "stats",
          "methods")'.  (Set 'R_DEFAULT_PACKAGES' to 'NULL' or a
          comma-separated list of package names.)   A call to 'options'
          should be in your '.Rprofile' file to ensure that the change
          takes effect before the base package is initialized (see
          'Startup').

     '_d_e_p_a_r_s_e._m_a_x._l_i_n_e_s': controls the number of lines used when
          deparsing in 'traceback' and 'browser'.  Initially unset, and
          only used if set to a positive integer.

     '_d_i_g_i_t_s': controls the number of digits to print when printing
          numeric values.  It is a suggestion only.  Valid values are
          1...22 with default 7.  See the warning in 'print.default'
          about values greater than 15.

     '_d_i_g_i_t_s._s_e_c_s': controls the maximum number of digits to print when
          formatting time values in seconds.  Valid values are 0...6
          with default 0.  See 'strftime'.

     '_d_o_w_n_l_o_a_d._f_i_l_e._m_e_t_h_o_d': Method to be used for 'download.file'. 
          Currently download methods '"internal"', '"wget"' and
          '"lynx"' are available. There is no default for this option,
          when 'method = "auto"' is chosen: see 'download.file'.

     '_e_c_h_o': logical.  Only used in non-interactive mode, when it
          controls whether input is echoed.  Command-line option
          '--slave' sets this to 'FALSE', but otherwise it starts the
          session as 'TRUE'.

     '_e_n_c_o_d_i_n_g': The name of an encoding, default '"native.enc"').  See
          'connections'.

     '_e_r_r_o_r': either a function or an expression governing the handling
          of non-catastrophic errors such as those generated by 'stop'
          as well as by signals and internally detected errors.  If the
          option is a function, a call to that function, with no
          arguments, is generated as the expression.  The default value
          is 'NULL': see 'stop' for the behaviour in that case.  The
          functions 'dump.frames' and 'recover' provide alternatives
          that allow post-mortem debugging.  Note that these need to
          specified as e.g. 'options=utils::recover' in startup files
          such as '.Rprofile'.

     '_e_x_p_r_e_s_s_i_o_n_s': sets a limit on the number of nested expressions
          that will be evaluated.  Valid values are 25...500000 with
          default 5000.  If you increase it, you may also want to start
          R with a larger protection stack; see '--max-ppsize' in
          'Memory'.  Note too that you may cause a segfault from
          overflow of the C stack, and on OSes where it is possible you
          may want to increase that.

     '_k_e_e_p._s_o_u_r_c_e': When 'TRUE', the source code for functions (newly
          defined or loaded) is stored in their '"source"' attribute
          (see 'attr') allowing comments to be kept in the right
          places.

          The default is 'interactive()', i.e., 'TRUE' for interactive
          use.

     '_k_e_e_p._s_o_u_r_c_e._p_k_g_s': As for 'keep.source', for functions in
          packages loaded by 'library' or 'require'.  Defaults to
          'FALSE' unless the environment variable 'R_KEEP_PKG_SOURCE'
          is set to 'yes'.

          Note this does not apply to packages using lazy-loading or
          saved images.  Whether they have kept source is determined
          when they are installed (and is almost certainly false).

     '_m_a_i_l_e_r': default mailer used by 'bug.report()'.  Can be '"none"'.

     '_m_a_x._c_o_n_t_o_u_r._s_e_g_m_e_n_t_s': positive integer, defaulting to '250000'
          and usually not set.  A limit on the number of segments in a
          single contour line in 'contour' or 'contourLines'.

     '_m_a_x._p_r_i_n_t': integer, defaulting to '99999'. 'print' or 'show'
          methods can make use of this option, to limit the amount of
          information that is printed, to something in the order of
          (and typically slightly less than) 'max.print' _entries_.

     '_O_u_t_D_e_c': character string containing a single-byte character. 
          The character to be used as the decimal point in output
          conversions, that is in printing, plotting and 'as.character'
          but not deparsing.

     '_p_a_g_e_r': the command used for displaying text files by
          'file.show'. Defaults to 'R_HOME/bin/pager', which selects a
          pager via the 'PAGER' environment variable (and that usually
          defaults to 'less'). Can be a character string or an R
          function, in which case it needs to accept the same first
          four arguments as 'file.show'.

     '_p_a_p_e_r_s_i_z_e': the default paper format used by 'postscript';  set
          by environment variable 'R_PAPERSIZE' when R is started: if
          that is unset or invalid it defaults to a value derived from
          the locale category 'LC_PAPER', or if that is unavailable to
          a default set when R was built.


     '_p_d_f_v_i_e_w_e_r': default PDF viewer. The default is set from the
          environment variable 'R_PDFVIEWER'.


     '_p_r_i_n_t_c_m_d': the command used by 'postscript' for printing; set by
          environment variable 'R_PRINTCMD' when R is started.  This
          should be a command that expects either input to be piped to
          'stdin' or to be given a single filename argument.

     '_p_r_o_m_p_t': a non-empty string to be used for R's prompt; should
          usually end in a blank ('" "').

     '_r_l__w_o_r_d__b_r_e_a_k_s': Used for the readline-based terminal interface. 
          Default value '" \t\n\"\\'`><=%;,|&{()}"'. This is the set of
          characters use to break the input line up into tokens for
          object- and file-name completion.  Those who do not use
          spaces around operators may prefer '"
          \t\n\"\\'`><=+-*%;,|&{()}"'. which was the default in R
          2.5.0.  (The default in pre-2.5.0 versions of R was '"
          \t\n\"\\'`@$><=;|&{("'.)

     '_s_a_v_e._d_e_f_a_u_l_t_s', '_s_a_v_e._i_m_a_g_e._d_e_f_a_u_l_t_s': see 'save'.

     '_s_c_i_p_e_n': integer.  A penalty to be applied when deciding to print
          numeric values in fixed or exponential notation.  Positive
          values bias towards fixed and negative towards scientific
          notation: fixed notation will be preferred unless it is more
          than 'scipen' digits wider.

     '_s_h_o_w_W_a_r_n_C_a_l_l_s', '_s_h_o_w_E_r_r_o_r_C_a_l_l_s': a logical. Should warning and
          error messages show a summary of the call stack?  By default
          error calls are shown in non-interactive sessions.

     '_s_h_o_w_N_C_a_l_l_s': a integer.  Controls how long the sequence of calls
          must be (in bytes) before ellipses are used.  Defaults to 40
          and should be at least 30 and no more than 500.

     '_s_h_o_w._e_r_r_o_r._m_e_s_s_a_g_e_s': a logical.  Should error messages be
          printed?  Intended for use with 'try' or a user-installed
          error handler.

     '_s_t_r_i_n_g_s_A_s_F_a_c_t_o_r_s': The default setting for arguments of
          'data.frame' and 'read.table'.

     '_t_e_x_i_2_d_v_i': used by function 'texi2dvi' in package 'tools'. Set at
          startup from the environment variable 'R_TEXI2DVICMD'.


     '_t_i_m_e_o_u_t': integer.  The timeout for some Internet operations, in
          seconds.  Default 60 seconds.  See 'download.file' and
          'connections'.

     '_t_o_p_L_e_v_e_l_E_n_v_i_r_o_n_m_e_n_t': see 'topenv' and 'sys.source'.

     '_u_s_e_F_a_n_c_y_Q_u_o_t_e_s': see 'sQuote'.

     '_v_e_r_b_o_s_e': logical.  Should R report extra information on
          progress?  Set to 'TRUE' by the command-line option
          '-verbose'.

     '_w_a_r_n': sets the handling of warning messages.  If 'warn' is
          negative all warnings are ignored.  If 'warn' is zero (the
          default) warnings are stored until the top-level function
          returns.  If fewer than 10 warnings were signalled they will
          be printed otherwise a message saying how many (max 50) were
          signalled.  An object called 'last.warning' is created and
          can be printed through the function 'warnings'.  If 'warn' is
          one, warnings are printed as they occur.  If 'warn' is two or
          larger all warnings are turned into errors.

     '_w_a_r_n_E_s_c_a_p_e_s': logical.  If true (the default) the parser warns on
          unrecognized (backslash) escape sequences and there is a
          truncation warning on any attempt to create a character
          string containing an embedded nul.

     '_w_a_r_n_P_a_r_t_i_a_l_M_a_t_c_h_A_r_g_s': logical.  If true, warns if partial
          matching is used in argument matching.

     '_w_a_r_n_P_a_r_t_i_a_l_M_a_t_c_h_A_t_t_r': logical.  If true, warns if partial
          matching is used in extracting attributes via 'attr'.

     '_w_a_r_n_P_a_r_t_i_a_l_M_a_t_c_h_D_o_l_l_a_r': logical.  If true, warns if partial
          matching is used for extraction by '$'.

     '_w_a_r_n_i_n_g._e_x_p_r_e_s_s_i_o_n': an R code expression to be called if a
          warning is generated, replacing the standard message.  If
          non-null it is called irrespective of the value of option
          'warn'.

     '_w_a_r_n_i_n_g._l_e_n_g_t_h': sets the truncation limit for error and warning
          messages.  A non-negative integer, with allowed values
          100...8170, default 1000.

     '_w_i_d_t_h': controls the maximum number of columns on a line used in
          printing vectors, matrices and arrays, and when filling by
          'cat'.

          Columns are normally the same as characters except in CJK
          languages.

          You may want to change this if you re-size the window that R
          is running in.  Valid values are 10...10000 with default
          normally 80.  (The limits on valid values are in file
          'Print.h' and can be changed by re-compiling R.)  Some R
          consoles automatically change the value when they are
          resized.


     The 'factory-fresh' default settings of some of these options are

       'add.smooth'           'TRUE'
       'check.bounds'         'FALSE'
       'continue'             '"+ "'
       'digits'               '7'
       'echo'                 'TRUE'
       'encoding'             '"native.enc"'
       'error'                'NULL'
       'expressions'          '5000'
       'keep.source'          'interactive()'
       'keep.source.pkgs'     'FALSE'
       'max.print'            '99999'
       'OutDec'               '"."'
       'prompt'               '"> "'
       'scipen'               '0'
       'show.error.messages'  'TRUE'
       'timeout'              '60'
       'verbose'              'FALSE'
       'warn'                 '0'
       'warnings.length'      '1000'
       'width'                '80'

     Others are set from environment variables or are
     platform-dependent.

_O_p_t_i_o_n_s _s_e_t _i_n _p_a_c_k_a_g_e _g_r_D_e_v_i_c_e_s:

     These will be set when package 'grDevices' (or its name space) is
     loaded if not already set.

     '_d_e_v_i_c_e': a character string giving the name of a function, or the
          function object itself, which when called creates a new
          graphics device of the default type for that session.  The
          value of this option defaults to the normal screen device
          (e.g., 'X11', 'windows' or 'quartz') for an interactive
          session, and 'pdf' in batch use or if a screen is not
          available.  If set to the name of a device, the device is
          looked for first from the global environment (that is down
          the usual search path) and then in the 'grDevices' namespace.

          The default values in interactive and non-interactive
          sessions are configurable via environment variables
          'R_INTERACTIVE_DEVICE' and 'R_DEFAULT_DEVICE' respectively.


     '_l_o_c_a_t_o_r_B_e_l_l': logical.  Should selection in 'locator' and
          'identify' be confirmed by a bell?  Default 'TRUE'. Honoured
          at least on 'X11' and 'windows' devices.

     '_d_e_v_i_c_e._a_s_k._d_e_f_a_u_l_t': logical.  The default for
          'devAskNewPage("ask")' when a device is opened.

     '_b_i_t_m_a_p_T_y_p_e': character.  The default type for the bitmap devices
          such as 'png'.  Defaults to '"cairo"' on systems where that
          is available, or to '"quartz"' on Mac OS X where that is
          available.

_O_p_t_i_o_n_s _s_e_t _i_n _p_a_c_k_a_g_e _s_t_a_t_s:

     These will be set when package 'stats' (or its name space) is
     loaded if not already set.

     '_c_o_n_t_r_a_s_t_s': the default 'contrasts' used in model fitting such as
          with 'aov' or 'lm'. A character vector of length two, the
          first giving the function to be used with unordered factors
          and the second the function to be used with ordered factors. 
          By default the elements are named 'c("unordered",
          "ordered")', but the names are unused.

     '_n_a._a_c_t_i_o_n': the name of a function for treating missing values
          ('NA''s) for certain situations.

     '_s_h_o_w._c_o_e_f._P_v_a_l_u_e_s': logical, affecting whether P values are
          printed in summary tables of coefficients.  See
          'printCoefmat'.

     '_s_h_o_w._s_i_g_n_i_f._s_t_a_r_s': logical, should stars be printed on summary
          tables of coefficients?  See 'printCoefmat'.

     '_t_s._e_p_s': the relative tolerance for certain time series ('ts')
          computations.  Default '1e-05'.

     '_t_s._S._c_o_m_p_a_t': logical.  Used to select S compatibility for
          plotting time-series spectra.  See the description of
          argument 'log' in 'plot.spec'.

_O_p_t_i_o_n_s _s_e_t _i_n _p_a_c_k_a_g_e _u_t_i_l_s:

     These will be set when package 'utils' (or its name space) is
     loaded if not already set.

     '_b_r_o_w_s_e_r': default HTML browser used by 'help.start()' and
          'browseURL' on UNIX, or a non-default browser on Windows. 
          Alternatively, an R function that is called with a URL as its
          argument. 

     '_d_e._c_e_l_l_w_i_d_t_h': integer: the cell widths (number of characters) to
          be used in the data editor 'dataentry'. If this is unset (the
          default), 0, negative or 'NA', variable cell widths are used.

     '_d_e_m_o._a_s_k': default for the 'ask' argument of 'demo'.      

     '_e_d_i_t_o_r': a non-empty string, or a function that is called with a
          file path as argument. Sets the default text editor, e.g.,
          for 'edit'.  Set from the environment variable 'VISUAL' on
          UNIX.

     '_e_x_a_m_p_l_e._a_s_k': default for the 'ask' argument of 'example'.

     '_h_e_l_p._t_r_y._a_l_l._p_a_c_k_a_g_e_s': default for an argument of 'help'.

     '_H_T_T_P_U_s_e_r_A_g_e_n_t': string used as the user agent in HTTP requests. 
          If 'NULL', HTTP requests will be made without a user agent
          header.  The default is 'R (<version> <platform> <arch>
          <os>)'

     '_i_n_t_e_r_n_e_t._i_n_f_o': The minimum level of information to be printed on
          URL downloads etc.  Default is 2, for failure causes. Set to
          1 or 0 to get more information.

     '_m_e_n_u._g_r_a_p_h_i_c_s': Logical: should graphical menus be used if
          available?.  Defaults to 'TRUE'.  Currently applies to
          'chooseCRANmirror', 'setRepositories' and to select from
          multiple help files in 'help'.

     '_p_k_g_T_y_p_e': The default type of packages to be downloaded and
          installed - see 'install.packages'. Possible values are
          '"source"' (the default except under the CRAN Mac OS X build)
          and '"mac.binary"'. The latter can have a suffix if supported
          by a special build, such as '"mac.binary.leopard"' to access
          the '"leopard"' tree of repositories instead of the default
          '"universal"'.


     '_r_e_p_o_s': URLs of the repositories for use by 'update.packages'. 
          Defaults to 'c(CRAN="@CRAN@")', a value that causes some
          utilities to prompt for a CRAN mirror.  To avoid this do set
          the CRAN mirror, by something like 'local({r <-
          getOption("repos"); r["CRAN"] <- "http://my.local.cran";
          options(repos=r)})'.

          Note that you can add more repositories (Bioconductor and
          Omegahat, notably) using 'setRepositories()'.

     '_S_w_e_a_v_e_H_o_o_k_s', '_S_w_e_a_v_e_S_y_n_t_a_x': see 'Sweave'.

     '_u_n_z_i_p': a character string, the path of the command used for
          unzipping help files, or '"internal"'. Defaults to the value
          of 'R_UNZIPCMD', which is set in 'etc/Renviron' if an 'unzip'
          command was found during configuration.


_O_p_t_i_o_n_s _u_s_e_d _o_n _U_n_i_x _o_n_l_y:

     These will be '""' if no suitable path is known.

     '_l_a_t_e_x_c_m_d, _d_v_i_p_s_c_m_d': character strings giving commands to be used
          in off-line printing of help pages.

_R_e_f_e_r_e_n_c_e_s:

     Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) _The New S
     Language_. Wadsworth & Brooks/Cole.

_E_x_a_m_p_l_e_s:

     op <- options(); utils::str(op) # op() may contain functions.

     getOption("width") == options()$width # the latter needs more memory
     options(digits = 15)
     pi

     # set the editor, and save previous value
     old.o <- options(editor = "nedit")
     old.o

     options(check.bounds = TRUE, warn = 1)
     x <- NULL; x[4] <- "yes" # gives a warning

     options(digits=5)
     print(1e5)
     options(scipen=3); print(1e5)

     options(op)     # reset (all) initial options
     options("digits")

     ## Not run: 
     ## set contrast handling to be like S
     options(contrasts = c("contr.helmert", "contr.poly"))
     ## End(Not run)

     ## Not run: 
     ## on error, terminate the R session with error status 66
     options(error = quote(q("no", status=66, runLast=FALSE)))
     stop("test it")
     ## End(Not run)

     ## Not run: 
     ## Set error actions for debugging:
     ## enter browser on error, see ?recover:
     options(error = recover)
     ## allows to call debugger() afterwards, see ?debugger:
     options(error = dump.frames)
     ## A possible setting for non-interactive sessions
     options(error = quote({dump.frames(to.file=TRUE); q()}))
     ## End(Not run)

