options(…)getOption(x, default = NULL)
.Options
name = value
.
However, only the ones below are used in base R.Options can also be passed by giving a single unnamed argument which is a named list.
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).add.smooth
: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
.browserNLdisabled
:"n"
in the browser.checkPackageLicense
:loadNamespace
asks a user to accept any
non-standard license at first load of the package.
check.bounds
:FALSE
. If
true, a warning is produced whenever a
vector (atomic or list
) is extended, by something
like x <- 1:3; x[5] <- 6
.CBoundsCheck
:.C
and .Fortran
make copies to check for
array over-runs on the atomic vector arguments. Initially set from value of the environment variable
R_C_BOUNDS_CHECK
(set to yes
to enable).continue
:defaultPackages
: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.) It will not work to set
this in a .Rprofile
file, as its value is consulted before
that file is read.deparse.cutoff
:deparse
d.
Default 60
.
deparse.max.lines
:traceback
, browser
,
and upon entry to a function whose debugging flag is set.
Initially unset, and only used if set to a positive integer.digits
:print.default
about values greater than 15.digits.secs
:strftime
.download.file.extra
:download.file
.download.file.method
:download.file
. Currently download methods
"internal"
, "wininet"
(Windows only),
"libcurl"
, "wget"
and "curl"
are available.
If not set, method = "auto"
is chosen: see download.file
.echo
:FALSE
, but otherwise
it starts the session as TRUE
.encoding
:"native.enc"
. See connections
.error
: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(error = utils::recover)
in startup
files such as .Rprofile
.expressions
: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. Once the
limit is reached an error is thrown. The current number under
evaluation can be found by calling Cstack_info
.interrupt
:keep.source
:TRUE
, the source code for
functions (newly defined or loaded) is stored internally
allowing comments to be kept in the right places. Retrieve the
source by printing or using deparse(fn, control =
"useSource")
. The default is interactive()
, i.e., TRUE
for
interactive use.keep.source.pkgs
:keep.source
, used only
when packages are installed. Defaults to FALSE
unless the
environment variable R_KEEP_PKG_SOURCE
is set to yes
.matprod
:%*%
, crossprod
, and
tcrossprod
for double and complex vectors:
"internal"
NaN
and
Inf
values and is consistent in precision with
other summation algorithms inside R like sum
or
colSums
(which now means that it uses a long
double
accumulator for summation if available and enabled,
see capabilities
)."default"
NaN
and Inf
values it uses an unoptimized 3-loop algorithm for inputs that may
contain NaN
or Inf
values. When deemed
beneficial for performance, "default"
may call the
3-loop algorithm unconditionally, i.e., without checking the
input for NaN/Inf values. The 3-loop algorithm uses (only) a
double
accumulator for summation, which is consistent
with the reference BLAS implementation."blas"
NaN
or
Inf
values correctly and for inputs with
NaN
/Inf
values the results may be undefined."default.simd"
"default"
, but the check whether the input contains
NaN/Inf values is faster on some SIMD hardware. On older
systems it will run correctly, but may be much slower than
"default"
.max.print
: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.OutDec
:format
and as.character
but not when
deparsing nor by sprintf
nor formatC
(which are sometimes used prior to printing.)
pager
:file.show
.
Defaults to R_HOME/bin/pager
, which is a shell
script running the command-line specified by the environment
variable PAGER
whose default is set at configuration,
usually to less
.
Defaults to "internal"
, which uses a pager similar to the
GUI console. Another possibility is "console"
to use the
console itself.
Can be a character string or an R function, in which case it
needs to accept the arguments (files, header,
title, delete.file)
corresponding to the first four arguments of
file.show
.papersize
: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.
"a4"
, or "letter"
in US and Canadian locales.
PCRE_limit_recursion
:grep(perl = TRUE)
and similar limit the maximal
recursion allowed when matching? PCRE can be built not to use a
recursion stack (see pcre_config
, but it is by
default with a recursion limit of 10000000 which potentially needs
a very large C stack: see the discussion at
http://www.pcre.org/original/doc/html/pcrestack.html. If
true, the limit is reduced using R's estimate of the C stack size
available (if known), otherwise 10000. If NA
, the limit is
imposed only if any input string has 1000 or more bytes.PCRE_study
:grep(perl = TRUE)
and similar ‘study’ the
patterns? Either logical or a numerical threshold for the minimum
number of strings to be matched for the pattern to be studied (the
default is 10
)). Missing values and negative numbers are
treated as false.PCRE_use_JIT
:grep(perl =
TRUE)
, strsplit(perl = TRUE)
and similar make use
of PCRE's Just-In-Time compiler for studied patterns, if
available? Missing values are treated as false.pdfviewer
:R_PDFVIEWER
,
the default value of which is set when R is configured.
which defaults to the full path to open.exe
, a utility
supplied with R.
printcmd
: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. Usually set to "lpr"
on a Unix-alike.prompt
:" "
).rl_word_breaks
:" \t\n\"\\'`><=%;,|&{()}"
. This is the set of characters use to break the input line into
tokens for object- and file-name completion. Those who do not use
spaces around operators may prefer
" \t\n\"\\'`><=+-*%;,|&{()}"
save.defaults
, save.image.defaults
:save
.scipen
:scipen
digits wider.showWarnCalls
, showErrorCalls
:showNCalls
:show.error.locations
:TRUE
or "top"
, the
source location that is highest on the stack (the most recent
call) will be printed. "bottom"
will print the location
of the earliest call found on the stack. Integer values can select other entries. The value 0
corresponds to "top"
and positive values count down the
stack from there. The value -1
corresponds to
"bottom"
and negative values count up from there.
show.error.messages
:try
or a
user-installed error handler.stringsAsFactors
:data.frame
and read.table
.texi2dvi
:texi2dvi
and texi2pdf
in package tools.
Set at startup from the environment variable R_TEXI2DVICMD
,
which defaults first to the value of environment variable
TEXI2DVI
, and then to a value set when R was installed (the
full path to a texi2dvi
script if one was found). If
necessary, that environment variable can be set to "emulation"
.
timeout
:download.file
and connections
.topLevelEnvironment
:topenv
and
sys.source
.url.method
:url
. Normally unset, which is equivalent to
"default"
, which is "internal"
except on Windows.useFancyQuotes
:sQuote
, dQuote
and in
rendering text help (see Rd2txt
in package
tools). Can be TRUE
, FALSE
, "TeX"
or
"UTF-8"
.verbose
:TRUE
by the command-line option
--verbose.warn
:warn
is negative all warnings are ignored. If warn
is zero (the default) warnings are stored until the top--level
function returns. If 10 or fewer warnings were signalled they
will be printed otherwise a message saying how many 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.warnPartialMatchArgs
:warnPartialMatchAttr
:attr
.warnPartialMatchDollar
:$
.warning.expression
:warn
.warning.length
:nwarnings
:warn = 0
, default 50. This will discard messages if
called whilst they are being collected. If you increase this
limit, be aware that the current implementation pre-allocates
the equivalent of a named list for them, i.e., do not increase it to
more than say a million.width
:cat
. Columns are normally the same as characters except in East Asian
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. See the examples on Startup for one way to set this
automatically from the terminal width when R is started.
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 |
warning.length |
1000 |
width |
80 |
bitmapType
:png
. Defaults to
"cairo"
on systems where that is available, or to
"quartz"
on macOS where that is available.device
: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. The search logic for ‘the normal screen device’ is that
this is windows
on Windows, and quartz
if available
on macOS (running at the console, and compiled into the build).
Otherwise X11
is used if environment variable DISPLAY
is set.
device.ask.default
:devAskNewPage("ask")
when a device is opened.locatorBell
:locator
and identify
be confirmed by a bell? Default TRUE
.
Honoured at least on X11
and windows
devices.windowsTimeout
:windows
devices when that is
enabled: the first is the delay after plotting finishes
(default 100) and the second is the update interval during
continuous plotting (default 500). The values at the time the
device is opened are used.max.contour.segments
:25000
if not set. A limit on the number of
segments in a single contour line in contour
or
contourLines
.contrasts
: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.na.action
:NA
's) for certain situations, see
na.action
and na.pass
.show.coef.Pvalues
:printCoefmat
.show.nls.convergence
:nls
convergence messages be printed for successful fits?show.signif.stars
:printCoefmat
.ts.eps
:ts
) computations. Default 1e-05
.ts.S.compat
:log
in plot.spec
.BioC_mirror
:setRepositories
,
e.g. the default "https://bioconductor.org"
or the European mirror
"https://bioconductor.statistik.tu-dortmund.de". Can be set
by chooseBioCmirror
.browser
:browseURL
. This sets the default browser on UNIX or
a non-default browser on Windows. Alternatively, an R function
that is called with a URL as its argument. See
browseURL
for further details.ccaddress
:create.post
(and hencebug.report
and
help.request
). Can be FALSE
or ""
.citation.bibtex.max
:bibentry
) in a citation
for
which the bibtex version is printed in addition to the text one.de.cellwidth
:dataentry
.
If this is unset (the default), 0, negative or NA
, variable
cell widths are used.demo.ask
:ask
argument of
demo
.editor
:edit
. Set from the
environment variable EDITOR
on UNIX, or if unset
VISUAL
or vi
.example.ask
:ask
argument of
example
.help.ports
:startDynamicHelp
.help.search.types
:help.search
and ??
.help.try.all.packages
:help
.help_type
:help
, used also as the help type by ?
.HTTPUserAgent
:NULL
, requests will be made without a
user agent header.
The default is R (<version> <platform> <arch> <os>)
.install.lock
:install.packages
? Most useful
for binary installs on macOS and Windows, but can be used in a
startup file for source installs via
R CMD INSTALL
. For binary installs, can also be
the character string "pkgloack"
.internet.info
:"internal"
and
"libcurl"
methods.
Default is 2, for failure causes. Set to 1 or 0 to get more
detailed information (for the "internal"
method 0 provides
more information than 1).
install.packages.check.source
:install.packages
(and indirectly
update.packages
) on platforms which support binary
packages. Possible values "yes"
and "no"
, with
unset being equivalent to "yes"
.install.packages.compile.from.source
:install.packages(type = "both")
(and indirectly
update.packages
) on platforms which
support binary packages. Possible values are "never"
,
"interactive"
(which means ask in interactive use and
"never"
in batch use) and "always"
. The default is
taken from environment variable
R_COMPILE_AND_INSTALL_PACKAGES
, with default
"interactive"
if unset. However, install.packages
uses "never"
unless a make
program is found,
consulting the environment variable MAKE
.mailer
:create.post
and hence bug.report
and
help.request
.menu.graphics
:TRUE
. Currently applies to
select.list
, chooseCRANmirror
,
setRepositories
and to select from multiple (text)
help files in help
.pkgType
:install.packages
.
Possible values are "win.binary"
, "source"
and
"both"
(the default). Some macOS builds use
"mac.binary.el-capitan"
.
Possible values are "source"
(the default except under a
CRAN macOS build), "mac.binary.el-capitan"
and
"both"
(the default for CRAN macOS builds). Windows uses
"win.binary"
. ("mac.binary.mavericks"
,
"mac.binary.leopard"
, "mac.binary.universal"
are no
longer in use.)
Value "binary"
is a synonym for the native binary type (if
there is one); "both"
is used by
install.packages
to choose between source and binary
installs.
repos
: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,
R-Forge, Rforge.net …)
using setRepositories
.
SweaveHooks
, SweaveSyntax
:Sweave
.
unzip
:unzip
:
the path of the external program unzip
or "internal"
.
Defaults to the value of R_UNZIPCMD
, which is set in
etc/Renviron
if an unzip
command was found during
configuration.
Defaults to "internal"
when the internal unzip code is
used.
useHTTPS
:chooseCRANmirror
:
are secure mirrors preferred? If not set, TRUE
is assumed.mc.cores
:MC_CORES
if set. Most applications
which use this assume a limit of 2
if it is unset.
dvipscmd
:"dvips"
.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, e.g., getOption("width")
rather than
options("width")
which is a list of length one.op <- options(); utils::str(op) # op is a named list
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"))
## ---------------------------------------------
## Not run: ------------------------------------
# ## on error, terminate the R session with error status 66
# options(error = quote(q("no", status = 66, runLast = FALSE)))
# stop("test it")
## ---------------------------------------------
## 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()}))
## ---------------------------------------------
# Compare the two ways to get an option and use it
# acconting for the possibility it might not be set.
if(as.logical(getOption("performCleanp", TRUE)))
cat("do cleanup\n")
## Not run: ------------------------------------
# # a clumsier way of expressing the above w/o the default.
# tmp <- getOption("performCleanup")
# if(is.null(tmp))
# tmp <- TRUE
# if(tmp)
# cat("do cleanup\n")
## ---------------------------------------------
Run the code above in your browser using DataLab