options (base)

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

...

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.

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 (as a pairlist, unsorted), for S compatibility. Assigning to it will make a local copy and not change the original.

Value

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

Options used in base \R

<dl> <dt>add.smooth:</dt><dd>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.</dd>

<dt>check.bounds:</dt><dd>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.</dd>

<dt>continue:</dt><dd>a string setting the prompt used for lines which continue over one line.</dd>

<dt>defaultPackages:</dt><dd>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).</dd>

<dt>deparse.max.lines:</dt><dd>controls the number of lines used when deparsing in traceback and browser. Initially unset, and only used if set to a positive integer.</dd>

<dt>digits:</dt><dd>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.</dd>

<dt>digits.secs:</dt><dd>controls the maximum number of digits to print when formatting time values in seconds. Valid values are 0...6 with default 0. See strftime.</dd>

<dt>download.file.method:</dt><dd>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.</dd>

<dt>echo:</dt><dd>logical. Only used in non-interactive mode, when it controls whether input is echoed. Command-line option –slave sets this initially to FALSE.</dd>

<dt>encoding:</dt><dd>The name of an encoding, default “native.enc”). See connections.</dd>

<dt>error:</dt><dd>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.</dd>

<dt>expressions:</dt><dd>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.</dd>

<dt>keep.source:</dt><dd>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.</dd>

<dt>keep.source.pkgs:</dt><dd>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).</dd>

<dt>mailer:</dt><dd>default mailer used by bug.report(). Can be “none”.</dd>

<dt>max.print:</dt><dd>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:.</dd>

<dt>OutDec:</dt><dd>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.</dd>

<dt>pager:</dt><dd>the (stand-alone) program used for displaying text files on :R:‘s console, also used by file.show and sometimes help. Defaults to \$R\_HOME/bin/pager.</dd>

<dt>papersize:</dt><dd>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 “a4”.</dd>

<dt>printcmd:</dt><dd>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.</dd>

<dt>prompt:</dt><dd>a string, used for :R:‘s prompt; should usually end in a blank (” “).</dd>

<dt>save.defaults, save.image.defaults:</dt><dd>see save.</dd>

<dt>scipen:</dt><dd>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.</dd>

<dt>show.error.messages:</dt><dd>a logical. Should error messages be printed? Intended for use with try or a user-installed error handler.</dd>

<dt>texi2dvi:</dt><dd>used by the unexported function texi2dvi in namespace [rp>tools].</dd>

<dt>timeout:</dt><dd>integer. The timeout for some Internet operations, in seconds. Default 60 seconds. See download.file and connections.</dd>

<dt>topLevelEnvironment:</dt><dd>see topenv and sys.source.</dd>

<dt>verbose:</dt><dd>logical. Should :R: report extra information on progress? Set to TRUE by the command-line option ‘–verbose’.</dd>

<dt>warn:</dt><dd>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.</dd>

<dt>warning.expression:</dt><dd>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.</dd>

<dt>warnings.length:</dt><dd>sets the truncation limit for error and warning messages. A non-negative integer, with allowed values 100...8192, default 1000.</dd>

<dt>width:</dt><dd>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 limits on valid values are in file Print.h and can be changed by re-compiling :R:.)</dd> </dl>

The ‘factory-fresh’ default settings of some of these options are \Tabular{ll}{ add.smooth \tab TRUE
check.bounds \tab FALSE
continue \tab “+ “
digits \tab 7
echo \tab TRUE
encoding \tab “native.enc”
error \tab NULL
expressions \tab 5000
keep.source \tab interactive()
keep.source.pkgs \tab FALSE
max.print \tab 1000
OutDec \tab “.”
prompt \tab “> “
scipen \tab 0
show.error.messages \tab TRUE
timeout \tab 60
verbose \tab FALSE
warn \tab 0
warnings.length \tab 1000
width \tab 80
} Others are set from environment variables or are platform-dependent.

Options set in package grDevices

These will be set when package [rp>grDevices] (or its name space) is loaded if not already set. <dl> <dt>device:</dt><dd>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.</dd>

<dt>locatorBell:</dt><dd>logical. Should selection in locator and identify be confirmed by a bell. Default TRUE. Honoured at least on X11 and windows devices.</dd>

<dt>X11colortype:</dt><dd>The default colour type for X11 devices. Default “true”.</dd>

<dt>X11fonts:</dt><dd>character vector of length 2. See X11.</dd>

<dt>gamma:</dt><dd>double. The default value of gamma for X11 devices, defaulting to 1 if unset (the default).</dd> </dl>

Options set in package stats

These will be set when package [rp>stats] (or its name space) is loaded if not already set. <dl> <dt>contrasts:</dt><dd>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.</dd>

<dt>na.action:</dt><dd>the name of a function for treating missing values (NA‘s) for certain situations.</dd>

<dt>show.coef.Pvalues:</dt><dd>logical, affecting whether P values are printed in summary tables of coefficients. See printCoefmat.</dd>

<dt>show.signif.stars:</dt><dd>logical, should stars be printed on summary tables of coefficients? See printCoefmat.</dd>

<dt>ts.eps:</dt><dd>the relative tolerance for certain time series (ts) computations. Default 1e-05.</dd>

<dt>ts.S.compat:</dt><dd>logical. Used to select S compatibility for plotting time-series spectra. See the description of argument log in plot.spec.</dd> </dl>

Options set in package utils

These will be set when package [rp>utils] (or its name space) is loaded if not already set. <dl> <dt>browser:</dt><dd>default HTML browser used by help.start() on UNIX, or a non-default browser on Windows.</dd>

<dt>de.cellwidth:</dt><dd>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.</dd>

<dt>editor:</dt><dd>sets the default text editor, e.g., for edit. Set from the environment variable VISUAL on UNIX.</dd>

<dt>help.try.all.packages:</dt><dd>default for an argument of help.</dd>

<dt>internet.info:</dt><dd>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.</dd>

<dt>pkgType:</dt><dd>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”.</dd>

<dt>repos:</dt><dd>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(). </dd> <dt>SweaveHooks, SweaveSyntax:</dt><dd>see Sweave.</dd>

<dt>unzip:</dt><dd>the command used for unzipping help files. Defaults to the value of ‘R\_UNZIPCMD‘, which is set in etc/Renviron if an unzip command was found during configuration.</dd> </dl>

Options used on Unix only

<dl> <dt>latexcmd, dvipscmd:</dt><dd>character strings giving commands to be used in off-line printing of help pages.</dd>

<dt>pdfviewer:</dt><dd>default PDF viewer. Set from the environment variable ‘R\_PDFVIEWER‘.</dd> </dl>

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('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, 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) 

Wiki discussion

 
rdoc/base/options.txt · Last modified: 2006/06/12
 
Recent changes RSS feed R Wiki powered by Driven by DokuWiki and optimized for Firefox Creative Commons License