What is the getOption() function in R?
Overview
The getOption() function in R allows a user to set and examine a range of global options that affect the way R computes and displays its results.
Syntax
options(…)
getOption(x, default = NULL)
.Options
Parameter values
The getOption() function takes the following parameter values:
...: This represents any options that can be defined usingname = value. It can be passed by giving a single unnamed argument which is a named list.
Below, we have a list of some options that are used in base R:
| Options | result |
|---|---|
| add.smooth | TRUE |
| check.bounds | FALSE |
| continue | “+” |
| digits | 7 |
| echo | TRUE |
| encoding | “native.enc” |
| expressions | 5000 |
x: This represents a character string that holds the option name.default: This is returned if the specified option is not set in the options list.
Example
# Implementing the getOption() functiongetOption("add.smooth")getOption("check.bounds")getOption("continue")getOption("digits")getOption("echo")getOption("encoding")getOption("error")
Explanation
In the code above, we use the getOption() function to examine certain global options that affect the way R works.