R - Option (Global Options)

> Procedural Languages > R

1 - About

Global Option in R

3 - Management

3.1 - List

  • all options
list = options() 
  • one
(list|null)= options(optionName)
Advertising

3.2 - Get

getOption('optionName', default = NULL)

3.3 - Set

  • Set the editor and save the previous value
old.o <- options(editor = "nedit")

3.4 - If then

if(as.logical(getOption("performCleanp", TRUE)))
   cat("do cleanup\n")
 
# or
tmp <- getOption("performCleanup")
if(is.null(tmp))
  tmp <- TRUE
if(tmp)
   cat("do cleanup\n")