Learn R Programming

formula.tools (version 1.7.1)

get.vars: Get variable (names) from various R objects

Description

get.vars extracts variable names from various R objects such as formulas, expressions, calls, symbols, etc. It is very similar to all.vars except that all symbols, etc. are interpolated to the names of variables.

Usage

get.vars(x, data = NULL, ...)

# S4 method for formula,ANY get.vars(x, data = NULL, ...)

# S4 method for call,ANY get.vars(x, data = NULL, ...)

# S4 method for expression,missing get.vars(x, data = NULL, ...)

# S4 method for name,ANY get.vars(x, data = NULL, ...)

# S4 method for ANY,ANY get.vars(x, data = NULL, ...)

# S4 method for `NULL`,ANY get.vars(x, data = NULL, ...)

lhs.vars(x, ...)

.lhs.vars(x, ..., data = NULL)

# S4 method for formula lhs.vars(x, ..., data = NULL)

# S4 method for call lhs.vars(x, ..., data = NULL)

# S4 method for expression lhs.vars(x, ...)

rhs.vars(x, ...)

.rhs.vars(x, ..., data = NULL)

# S4 method for formula rhs.vars(x, ..., data = NULL)

# S4 method for call rhs.vars(x, ..., data = NULL)

# S4 method for expression rhs.vars(x, ...)

Arguments

x

object to extract vars from.

data

data set/list or environment on which the names are defined

...

arguments passed to subsequent functions

get.vars and variant get the variables from objects optionally interpreting on . on the data. This is useful, for example, when you wish to know what data is used based on a given formula.

Methods/functions beginning with . are not exported

Value

character vector of variables names in order that they appear in x.

See Also

all.vars

Examples

Run this code
# NOT RUN {
  get.vars( Species ~ ., iris )
  get.vars( quote( Sepal.Length * Sepal.Width ), iris )
  
# }

Run the code above in your browser using DataLab