Aliases: options .Options getOption option MC_CORES R_C_BOUNDS_CHECK R_DEFAULT_DEVICE R_KEEP_PKG_SOURCE R_INTERACTIVE_DEVICE
Keywords: environment error print
### ** Examples op <- options(); utils::str(op) # op is a named list
List of 69 $ add.smooth : logi TRUE $ bitmapType : chr "cairo" $ browser : chr "/usr/bin/xdg-open" $ browserNLdisabled : logi FALSE $ CBoundsCheck : logi FALSE $ check.bounds : logi FALSE $ citation.bibtex.max : int 1 $ continue : chr "+ " $ contrasts : Named chr [1:2] "contr.treatment" "contr.poly" ..- attr(*, "names")= chr [1:2] "unordered" "ordered" $ defaultPackages : chr [1:6] "datasets" "utils" "grDevices" "graphics" ... $ demo.ask : chr "default" $ deparse.cutoff : int 60 $ device :function (width = 7, height = 7, ...) $ device.ask.default : logi FALSE $ digits : int 7 $ dvipscmd : chr "dvips" $ echo : logi TRUE $ editor : chr "vi" $ encoding : chr "native.enc" $ example.ask : chr "default" $ expressions : int 5000 $ help.search.types : chr [1:3] "vignette" "demo" "help" $ help.try.all.packages: logi FALSE $ HTTPUserAgent : chr "R (4.2.3 x86_64-pc-linux-gnu x86_64 linux-gnu) - RCloud (http://github.com/att/rcloud)" $ httr_oauth_cache : logi NA $ httr_oob_default : logi FALSE $ internet.info : int 2 $ keep.parse.data : logi TRUE $ keep.parse.data.pkgs : logi FALSE $ keep.source : logi TRUE $ keep.source.pkgs : logi FALSE $ knitr.in.progress : logi TRUE $ locatorBell : logi TRUE $ mailer : chr "mailto" $ matprod : chr "default" $ max.print : int 99999 $ menu.graphics : logi TRUE $ na.action : chr "na.omit" $ nwarnings : int 50 $ OutDec : chr "." $ pager : chr "/usr/local/R/4.2/bin/pager" $ papersize : chr "a4" $ PCRE_limit_recursion : logi NA $ PCRE_study : logi FALSE $ PCRE_use_JIT : logi TRUE $ pdfviewer : chr "/usr/bin/xdg-open" $ pkgType : chr "source" $ printcmd : chr "" $ prompt : chr "> " $ repos : Named chr "@CRAN@" ..- attr(*, "names")= chr "CRAN" $ rl_word_breaks : chr " \t\n\"\\'`><=%;,|&{()}" $ scipen : num 0 $ show.coef.Pvalues : logi TRUE $ show.error.messages : logi TRUE $ show.signif.stars : logi TRUE $ str :List of 7 ..$ strict.width : chr "no" ..$ digits.d : int 3 ..$ vec.len : int 4 ..$ list.len : int 99 ..$ deparse.lines : NULL ..$ drop.deparse.attr: logi TRUE ..$ formatNum :function (x, ...) $ str.dendrogram.last : chr "`" $ stringsAsFactors : logi FALSE $ texi2dvi : chr "texi2dvi" $ timeout : int 60 $ try.outFile : 'file' int 4 ..- attr(*, "conn_id")=<externalptr> $ ts.eps : num 1e-05 $ ts.S.compat : logi FALSE $ unzip : chr "/usr/bin/unzip" $ useFancyQuotes : logi FALSE $ verbose : logi FALSE $ warn : int 0 $ warning.length : int 1000 $ width : int 80
getOption("width") == options()$width # the latter needs more memory
[1] TRUE
options(digits = 15) pi
[1] 3.14159265358979
# set the editor, and save previous value old.o <- options(editor = "nedit") old.o
$editor [1] "vi"
options(check.bounds = TRUE, warn = 1) x <- NULL; x[4] <- "yes" # gives a warning
Warning in x[4] <- "yes": assignment outside vector/list limits (extending from 0 to 4)
options(digits = 5) print(1e5)
[1] 1e+05
options(scipen = 3); print(1e5)
[1] 100000
options(op) # reset (all) initial options options("digits")
$digits [1] 7
## Not run: ##D ## set contrast handling to be like S ##D options(contrasts = c("contr.helmert", "contr.poly")) ## End(Not run) ## Not run: ##D ## on error, terminate the R session with error status 66 ##D options(error = quote(q("no", status = 66, runLast = FALSE))) ##D stop("test it") ## End(Not run) ## Not run: ##D ## Set error actions for debugging: ##D ## enter browser on error, see ?recover: ##D options(error = recover) ##D ## allows to call debugger() afterwards, see ?debugger: ##D options(error = dump.frames) ##D ## A possible setting for non-interactive sessions ##D options(error = quote({dump.frames(to.file = TRUE); q()})) ## End(Not run) # 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")
do cleanup
## Not run: ##D # a clumsier way of expressing the above w/o the default. ##D tmp <- getOption("performCleanup") ##D if(is.null(tmp)) ##D tmp <- TRUE ##D if(tmp) ##D cat("do cleanup\n") ## End(Not run)