Rev 28127 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
\name{options}\alias{options}\alias{.Options}\alias{getOption}\title{Options Settings}\description{Allow the user to set and examine a variety of global \dQuote{options}which affect the way in which \R computes and displays its results.}\usage{options(\dots)getOption(x).Options}%%-- NOTE : Keep the list up-to-date,%%-- ==== Consider also the leading comments in ../../../main/options.c\arguments{\item{\dots}{any options can be defined, using \code{name = value}.However, only the ones below are used in \dQuote{base \R}.Further, \code{options('name') == options()['name']}, see the example.}\item{x}{a character string holding an option name.}}\details{Invoking \code{options()} with no arguments returns a list with thecurrent values of the options. Note that not all options listed beloware set initially. To access the value of a single option, one shoulduse \code{getOption("width")}, e.g., rather than\code{options("width")} which is a \emph{list} of length one.\code{.Options} also always contains the \code{options()} list, forS compatibility. You must use it \dQuote{read only} however.}\value{For \code{options}, a list (in any case) with the previous values ofthe options changed, or all options when no arguments were given.}\section{Options used in base \R}{\describe{\item{\code{prompt}:}{a string, used for \R's prompt; should usuallyend in a blank (\code{" "}).}\item{\code{continue}:}{a string setting the prompt used for lineswhich continue over one line.}\item{\code{width}:}{controls the number of characters on a line.You may want to change this if you re-size the window that \R isrunning in. Valid values are 10\dots10000 with default normally80. (The valid values are in file \file{Print.h} and can bechanged by re-compiling \R.)}\item{\code{digits}:}{controls the number of digits to print whenprinting numeric values. It is a suggestion only. Valid valuesare 1\dots22 with default 7. See \code{\link{print.default}}.}\item{\code{editor}:}{sets the default text editor, e.g., for\code{\link[utils]{edit}}. Set from the environment variable\code{VISUAL} on UNIX.}\item{\code{pager}:}{the (stand-alone) program used for displayingASCII files on \R's console, also used by \code{\link{file.show}} andsometimes \code{\link[utils]{help}}.#ifdef unixDefaults to \file{\$R\_HOME/bin/pager}.#endif#ifdef windowsDefaults to \code{"internal"}, which uses a pager similar to theGUI console. Another possibility is \code{"console"} to use theconsole itself.#endif}\item{\code{browser}:}{default HTML browser used by\code{\link[utils]{help.start}()} on UNIX, or a non-default browser onWindows.}#ifdef unix\item{\code{pdfviewer}:}{default PDF viewer. Set from theenvironment variable \env{R\_PDFVIEWER}.}#endif\item{\code{mailer}:}{default mailer used by\code{\link[utils]{bug.report}()}. Can be \code{"none"}.}\item{\code{contrasts}:}{the default \code{\link[utils]{contrasts}} used inmodel fitting such as with \code{\link[utils]{aov}} or \code{\link[utils]{lm}}.A character vector of length two, the first giving the function tobe used with unordered factors and the second the function to beused with ordered factors.}\item{\code{defaultPackages}:}{the packages that are attached bydefault when \R starts up. Initially set from value of theenvironment variables \env{R\_DefaultPackages}, or if that is unset%% default is set in ../../profile/Common.R :to \code{c("utils", "stats", "graphics", "methods")}. (Set\env{R\_DEFAULT\_PACKAGES} to \code{NULL} or a comma-separated listof package names.) A call to \code{options} should be in your\file{.Rprofile} file to ensure that the change takes effectbefore the base package is initialized (see \code{\link{Startup}}).}\item{\code{expressions}:}{sets a limit on the number of nestedexpressions that will be evaluated.Valid values are 25\dots100000 with default 500.}\item{\code{keep.source}:}{When \code{TRUE}, the source code forfunctions (newly defined or loaded) is stored in their\code{"source"} attribute (see \code{\link{attr}}) allowingcomments to be kept in the right places.The default is \code{\link{interactive}()}, i.e., \code{TRUE} forinteractive use.}\item{\code{keep.source.pkgs}:}{As for \code{keep.source}, forfunctions in packages loaded by \code{\link{library}} or\code{\link{require}}. Defaults to \code{FALSE} unless theenvironment variable \env{R\_KEEP\_PKG\_SOURCE} is set to\code{yes}.}\item{\code{na.action}:}{the name of a function for treating missingvalues (\code{\link{NA}}'s) for certain situations.}\item{\code{papersize}:}{the default paper format used by\code{\link[graphics]{postscript}}; set by environment variable\env{R\_PAPERSIZE} when \R is started and defaulting to\code{"a4"} if that is unset or invalid.}\item{\code{printcmd}:}{the command used by \code{\link[graphics]{postscript}}for printing; set by environment variable \env{R\_PRINTCMD} when\R is started. This should be a command that expects either inputto be piped to \file{stdin} or to be given a single filenameargument.#ifdef windowsSee \code{\link[graphics]{postscript}} for ways to set this up.#endif}#ifdef unix\item{\code{latexcmd, dvipscmd}:}{character strings giving commandsto be used in off-line printing of help pages.}#endif\item{\code{show.signif.stars, show.coef.Pvalues}:}{logical,affecting P value printing, see \code{\link[stats]{printCoefmat}}.}\item{\code{ts.eps}:}{the relative tolerance for certain time series(\code{\link[stats]{ts}}) computations.}\item{\code{error}:}{either a function or an expression governingthe handling of non-catastrophic errors such as those generated by\code{\link{stop}} as well as by signals and internally detectederrors. If the option is a function, a call to that function,with no arguments, is generated as the expression. The defaultvalue is \code{NULL}: see \code{\link{stop}} for the behaviour inthat case. The function \code{\link[utils]{dump.frames}} provides onealternative that allows post-mortem debugging.}\item{\code{show.error.messages}:}{a logical. Should error messagesbe printed? Intended for use with \code{\link{try}} or auser-installed error handler.}\item{\code{warn}:}{sets the handling of warning messages. If\code{warn} is negative all warnings are ignored. If \code{warn}is zero (the default) warnings are stored until the top--levelfunction returns. If fewer than 10 warnings were signalled theywill be printed otherwise a message saying how many (max 50) weresignalled. A top--level variable called \code{last.warning} iscreated and can be viewed through the function\code{\link{warnings}}. If \code{warn} is one, warnings areprinted as they occur. If \code{warn} is two or larger allwarnings are turned into errors.}\item{\code{warning.length}:}{sets the truncation limit for errorand warning messages. A non-negative integer, with allowed values100--8192, default 1000.}\item{\code{warning.expression}:}{an \R code expression to be calledif a warning is generated, replacing the standard message. Ifnon-null is called irrespective of the value of option\code{warn}.}#ifdef windows\item{\code{warn.FPU}:}{logical, by default undefined. If true,a \link{warning} is produced whenever \link{dyn.load} repairs thecontrol word damaged by a buggy DLL.}#endif\item{\code{check.bounds}:}{logical, defaulting to \code{FALSE}. Iftrue, a \link{warning} is produced whenever a \dQuote{generalizedvector} (atomic or \code{\link{list}}) is extended, by somethinglike \code{x <- 1:3; x[5] <- 6}.}\item{\code{echo}:}{logical. Only used in non-interactive mode,when it controls whether input is echoed. Command-line option\option{--slave} sets this initially to \code{FALSE}.}\item{\code{verbose}:}{logical. Should \R report extra informationon progress? Set to \code{TRUE} by the command-line option\option{--verbose}.}\item{\code{device}:}{a character string giving the default devicefor that session. This defaults to the normal screen device(e.g., \code{x11}, \code{windows} or \code{gtk}) for aninteractive session, and \code{postscript} in batch use or if ascreen is not available.}#ifdef unix\item{\code{X11colortype}:}{The default colour type for\code{\link[graphics]{X11}} devices.}#endif\item{\code{CRAN}:}{The URL of the preferred CRAN node for use by\code{\link[utils]{update.packages}}. Defaults to\url{http://cran.r-project.org}.}\item{\code{download.file.method}:}{Method to be used for\code{download.file}. Currently download methods\code{"internal"}, \code{"wget"} and \code{"lynx"} are available.There is no default for this option, when \code{method = "auto"}is chosen: see \code{\link[utils]{download.file}}.}\item{\code{unzip}:}{the command used for unzipping help files.#ifdef unixDefaults to the value of \env{R\_UNZIPCMD}, which is set in\file{etc/Renviron} if an \code{unzip} command was found duringconfiguration.}#endif#ifdef windowsDefaults to \code{"internal"} when the internal unzip code isused.}#endif\item{\code{de.cellwidth}:}{integer: the cell widths (number ofcharacters) to be used in the data editor \code{\link[utils]{dataentry}}.If this is unset, 0, negative or \code{NA}, variable cell widthsare used.}\item{\code{encoding}:}{An integer vector of length 256 holding aninput encoding. Defaults to \code{native.enc} (= \code{0:255}).See \code{\link{connections}}.}\item{\code{timeout}:}{integer. The timeout for some Internetoperations, in seconds. Default 60 seconds.See \code{\link[utils]{download.file}} and \code{\link{connections}}.}\item{\code{internet.info}:}{The minimum level of information to beprinted on URL downloads etc. Default is 2, for failure causes.Set to 1 or 0 to get more information.}\item{\code{scipen}:}{integer. A penalty to be appliedwhen deciding to print numeric values in fixed or exponentialnotation. Positive values bias towards fixed and negative towardsscientific notation: fixed notation will be preferred unless it ismore than \code{scipen} digits wider.}\item{\code{locatorBell}:}{logical. Should selection in \code{locator}and \code{identify} be confirmed by a bell. Default \code{TRUE}.Honoured at least on \code{X11} and \code{windows} devices.}#ifdef unix\item{\code{X11fonts}:}{character vector of length 2.See \code{\link[graphics]{X11}}.}#endif}The default settings of some of these options are\tabular{llll}{\code{prompt} \tab \code{"> "} \tab\code{continue} \tab \code{"+ "}\cr\code{width} \tab \code{80} \tab\code{digits} \tab \code{7}\cr\code{expressions} \tab \code{500} \tab\code{keep.source} \tab \code{TRUE}\cr\code{show.signif.stars} \tab \code{TRUE} \tab\code{show.coef.Pvalues} \tab \code{TRUE}\cr\code{na.action} \tab \code{na.omit} \tab\code{ts.eps} \tab \code{1e-5}\cr\code{error} \tab \code{NULL} \tab\code{show.error.messages} \tab \code{TRUE} \cr\code{warn} \tab \code{0}\tab\code{warning.length} \tab \code{1000}\cr\code{echo} \tab \code{TRUE} \tab\code{verbose} \tab \code{FALSE} \cr\code{scipen} \tab \code{0} \tab \code{locatorBell} \tab \code{TRUE}}Others are set from environment variables or are platform-dependent.}\references{Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)\emph{The New S Language}.Wadsworth \& Brooks/Cole.}\examples{options() # printing all current optionsop <- 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 memoryoptions(digits=20)pi# set the editor, and save previous valueold.o <- options(editor="nedit")old.ooptions(check.bounds = TRUE)x <- NULL; x[4] <- "yes" # gives a warningoptions(digits=5)print(1e5)options(scipen=3); print(1e5)options(op) # reset (all) initial optionsoptions('digits')\dontrun{## set contrast handling to be like Soptions(contrasts=c("contr.helmert", "contr.poly"))}\dontrun{## on error, terminate the R session with error status 66options(error=quote(q("no", status=66, runLast=FALSE)))stop("test it")}\dontrun{## set an error action for debugging: see ?debugger.options(error=dump.frames)## A possible setting for non-interactive sessionsoptions(error=quote({dump.frames(to.file=TRUE); q()}))}}\keyword{environment}\keyword{error}\keyword{print}