options {base}R Documentation

Options Settings


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






... 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.


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), for S compatibility. You must use it “read only” however.


For options, a list (in any case) with the previous values of the options changed, or all options when no arguments were given.

Options used in base R

a string, used for R's prompt; should usually end in a blank (" ").
a string setting the prompt used for lines which continue over one line.
controls the number of characters on a line. 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 valid values are in file ‘Print.h’ and can be changed by re-compiling R.)
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 print.default.
sets the default text editor, e.g., for edit. Set from the environment variable VISUAL on UNIX.
the (stand-alone) program used for displaying ASCII files on R's console, also used by file.show and sometimes help. Defaults to "internal", which uses a pager similar to the GUI console. Another possibility is "console" to use the console itself.
default HTML browser used by help.start() on UNIX, or a non-default browser on Windows.
default mailer used by bug.report(). Can be "none".
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.
the packages that are attached by default when R starts up. Initially set from value of the environment variables R_DefaultPackages, or if that is unset to c("utils", "stats", "graphics", "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).
sets a limit on the number of nested expressions that will be evaluated. Valid values are 25...100000 with default 5000.
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.

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.
the name of a function for treating missing values (NA's) for certain situations.
the default paper format used by postscript; set by environment variable R_PAPERSIZE when R is started and defaulting to "a4" if that is unset or invalid.
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. See postscript for ways to set this up.
show.signif.stars, show.coef.Pvalues:
logical, affecting P value printing, see printCoefmat.
the relative tolerance for certain time series (ts) computations.
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 function dump.frames provides one alternative that allows post-mortem debugging.
a logical. Should error messages be printed? Intended for use with try or a user-installed error handler.
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. A top–level variable called last.warning is created and can be viewed 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.
sets the truncation limit for error and warning messages. A non-negative integer, with allowed values 100–8192, default 1000.
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.
logical, by default undefined. If true, a warning is produced whenever dyn.load repairs the control word damaged by a buggy DLL.
logical, defaulting to FALSE. If true, a warning is produced whenever a “generalized vector” (atomic or list) is extended, by something like x <- 1:3; x[5] <- 6.
logical. Only used in non-interactive mode, when it controls whether input is echoed. Command-line option --slave sets this initially to FALSE.
integer, defaulting to 10000. print or show methods can make use of this option, to limit the amount of information that is printed, typically to something in the order max.print lines.

This is not yet used in base R.

logical. Should R report extra information on progress? Set to TRUE by the command-line option --verbose.
a character string giving the default device for that session. This defaults to the normal screen device (e.g., x11, windows or quartz) for an interactive session, and postscript in batch use or if a screen is not available.
The 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, use something like options(repos=c(CRAN="http://my.local.cran/R")).
The default type of packages to be downloaded and installed – see install.packages. Possible values are "win.binary" (the default) and "source".
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.
the command used for unzipping help files. Defaults to "internal" when the internal unzip code is used.
integer: the cell widths (number of characters) to be used in the data editor dataentry. If this is unset, 0, negative or NA, variable cell widths are used.
An integer vector of length 256 holding an input encoding. Defaults to native.enc (= 0:255). See connections.
integer. The timeout for some Internet operations, in seconds. Default 60 seconds. See download.file and connections.
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.
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.
logical. Should selection in locator and identify be confirmed by a bell. Default TRUE. Honoured at least on X11 and windows devices.

The default settings of some of these options are
prompt "> " continue "+ "
width 80 digits 7
expressions 5000 keep.source interactive()
show.signif.stars TRUE show.coef.Pvalues TRUE
na.action na.omit timeout 60
ts.eps 1e-5 error NULL
show.error.messages TRUE warn 0
warning.length 1000 echo TRUE
verbose FALSE scipen 0
locatorBell TRUE

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


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


options() # printing all current options
op <- options(); str(op) # nicer printing

# .Options is the same:
all(sapply(1:length(op), function(i) if(is.atomic(op[[i]]))
                         {all(.Options[[i]] == op[[i]])} else TRUE))

options('width')[[1]] == options()$width # the latter needs more memory

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

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

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

options(op)     # reset (all) initial options

## 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 an error action for debugging: see ?debugger.
## A possible setting for non-interactive sessions
options(error=quote({dump.frames(to.file=TRUE); q()}))
## End(Not run)

[Package base version 2.1.0 Index]