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': one-character string.  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_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'.

     '_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.

     '_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.

     '_p_d_f_v_i_e_w_e_r': default PDF viewer.  Set from the environment
          variable 'R_PDFVIEWER'.

_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)

