Learn R Programming

validate (version 1.1.5)

variables: Get variable names

Description

Generic function that extracts names of variables ocurring in R objects.

Usage

variables(x, ...)

# S4 method for rule variables(x, ...)

# S4 method for list variables(x, ...)

# S4 method for data.frame variables(x, ...)

# S4 method for environment variables(x, ...)

# S4 method for expressionset variables(x, as = c("vector", "matrix", "list"), dummy = FALSE, ...)

Arguments

x

An R object

...

Arguments to be passed to other methods.

as

how to return variables:

  • 'vector' Return the uniqe vector of variables occurring in x.

  • 'matrix' Return a boolean matrix, each row representing a rule, each column representing a variable.

  • 'list' Return a named list, each entry containing a character vector with variable names.

dummy

Also retrieve transient variables set with the := operator.

Methods (by class)

  • variables(rule): Retrieve unique variable names

  • variables(list): Alias to names.list

  • variables(data.frame): Alias to names.data.frame

  • variables(environment): Alias to ls

  • variables(expressionset): Variables occuring in x either as a single list, or per rule.

See Also

Other expressionset-methods: as.data.frame(), as.data.frame,expressionset-method, created(), description(), label(), meta(), names<-,rule,character-method, origin(), plot,validator-method, summary(), voptions()

Other expressionset-methods: as.data.frame(), as.data.frame,expressionset-method, created(), description(), label(), meta(), names<-,rule,character-method, origin(), plot,validator-method, summary(), voptions()

Examples

Run this code

v <- validator(
  root = y := sqrt(x)
 , average = mean(x) > 3
 , sum = x + y == z
)
variables(v)
variables(v,dummy=TRUE)
variables(v,matrix=TRUE)
variables(v,matrix=TRUE,dummy=TRUE)


Run the code above in your browser using DataLab