findUsedOptions: Find options set or read in R code

View source: R/options.R

findUsedOptionsR Documentation

Find options set or read in R code

Description

This analyzes R code to find any reference to an R option, e.g., options()$prompt, getOption("prompt", "> "), etc.

Usage

findUsedOptions(code, asNodes = FALSE)

Arguments

code

the R code

asNodes

a logical value which if TRUE returns the rstatic nodes from the abstract sytax tree, i.e., the language objects. If FALSE, the function gets the names of the options.

Value

If asNodes is FALSE, a character vector.

If asNodes is TRUE, a list of rstatic language objects.

Author(s)

Duncan Temple Lang

See Also

find_nodes

Examples

findUsedOptions(body(dev.new))
findUsedOptions(body(dev.new), TRUE)

# Shows can handle options in the default values of a function parameter.
f = function(x, ext = getOption("MyOpt", FALSE)) {
  if(ext)
    readLines(x)
  x
}
findUsedOptions(f)

duncantl/CodeAnalysis documentation built on April 28, 2024, 6:01 p.m.