| options {base} | R Documentation |
Options Settings
Description
Allow the user to set and examine a variety of global “options” which affect the way in which R computes and displays its results.
Usage
options(...)
getOption(x)
.Options
Arguments
... |
any options can be defined, using However, only the ones below are used in “base R”. Further, |
x |
a character string holding an option name. |
Details
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, for
S compatibility. You must use it “read only” however.
Value
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
prompt:a string, used for R's prompt; should usually end in a blank (
" ").continue:a string setting the prompt used for lines which continue over one line.
width: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.)
digits: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.editor:sets the default text editor, e.g., for
edit. Set from the environment variableVISUALon UNIX.pager:the (stand-alone) program used for displaying ASCII files on R's console. Defaults to ‘\$R\_HOME/bin/pager’.
browser:default HTML browser used by
help.start()on UNIX, or a non-default browser on Windows.mailer:default mailer used by
bug.report(). can be"none".contrasts:the default
contrastsused in model fitting such as withaovorlm. 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.defaultPackages: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 toc("methods", "ctest"). (SetR_DEFAULT_PACKAGEStoNULLor a comma-separated list of package names.) A call tooptionsshould be in your ‘.Rprofile’ file to ensure that the change takes effect before the base package is initialized (seeStartup).expressions:sets a limit on the number of nested expressions that will be evaluated. This is especially important on the Macintosh since stack overflow is likely if this is set too high. Valid values are 25...100000 with default 500.
keep.source:When
TRUE, the source code for functions (newly defined or loaded) is stored in their"source"attribute (seeattr) allowing comments to be kept in the right places.The default is
interactive(), i.e.,TRUEfor interactive use.keep.source.pkgs:As for
keep.source, for functions in packages loaded bylibraryorrequire. Defaults toFALSEunless the environment variableR_KEEP_PKG_SOURCEis set toyes.na.action:the name of a function for treating missing values (
NA's) for certain situations.papersize:the default paper format used by
postscript; set by environment variableR_PAPERSIZEwhen R is started and defaulting to"a4"if that is unset or invalid.printcmd:the command used by
postscriptfor printing; set by environment variableR_PRINTCMDwhen 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.latexcmd, dvipscmd:character strings giving commands to be used in off-line printing of help pages.
show.signif.stars, show.coef.Pvalues:logical, affecting P value printing, see
print.coefmat.ts.eps:the relative tolerance for certain time series (
ts) computations.error:either a function or an expression governing the handling of non-catastrophic errors such as those generated by
stopas 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 isNULL: seestopfor the behaviour in that case. The functiondump.framesprovides one alternative that allows post-mortem debugging.show.error.messages:a logical. Should error messages be printed? Intended for use with
tryor a user-installed error handler.warn:sets the handling of warning messages. If
warnis negative all warnings are ignored. Ifwarnis 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 calledlast.warningis created and can be viewed through the functionwarnings. Ifwarnis one, warnings are printed as they occur. Ifwarnis two or larger all warnings are turned into errors.warning.length:sets the truncation limit for error and warning messages. A non-negative integer, with allowed values 100–8192, default 1000.
warning.expression:an R code expression to be called if a warning is generated, replacing the standard message. If non-null is called irrespective of the value of option
warn.check.bounds:logical, defaulting to
FALSE. If true, a warning is produced whenever a “generalized vector” (atomic orlist) is extended, by something likex <- 1:3; x[5] <- 6.echo:logical. Only used in non-interactive mode, when it controls whether input is echoed. Command-line option
--slavesets this initially toFALSE.verbose:logical. Should R report extra information on progress? Set to
TRUEby the command-line option--verbose.device:a character string giving the default device for that session. This defaults to the normal screen device (e.g.,
x11,windowsorgtk) for an interactive session, andpostscriptin batch use or if a screen is not available.X11colortype:The default colour type for
X11devices.CRAN:The URL of the preferred CRAN node for use by
update.packages. Defaults to http://cran.r-project.org.download.file.method:Method to be used for
download.file. Currently download methods"internal","wget"and"lynx"are available. There is no default for this option, whenmethod = "auto"is chosen: seedownload.file.unzip:the command used for unzipping help files. Defaults to the value of
R\_UNZIPCMD, which is set in ‘etc/Renviron’ if anunzipcommand was found during configuration.
References
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth \& Brooks/Cole.
Examples
options() # printing all current options
op <- options(); str(op) # nicer printing
# .Options is the same:
all(sapply(1:length(op), function(i) all(.Options[[i]] == op[[i]])))
options('width')[[1]] == options()$width # the latter needs more memory
options(digits=20)
pi
# set the editor, and save previous value
old.o <- options(editor="nedit")
old.o
options(check.bounds = TRUE)
x <- NULL; x[4] <- "yes" # gives a warning
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 an error action for debugging: 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)