getvariables: Extract Variables or Variable Names

getvariablesR Documentation

Extract Variables or Variable Names

Description

getvarnames extracts the variables' names occurring in a formula, in raw form (as get\_all\_vars) or in transformed form (as model.frame does it).

getvariables collects variables from a data.frame

Usage

getvariables(formula, data = NULL, transformed = TRUE,
  envir = parent.frame(), ...)
getvarnames(formula, data = NULL, transformed = FALSE)

Arguments

formula

a model 'formula' or 'terms' object or an R object, or a character vector of variable names

data

a data.frame, list or environment (or object coercible by 'as.data.frame' to a data.frame), containing the variables in 'formula'. Neither a matrix nor an array will be accepted.

transformed

logical. If TRUE, variables will be extracted as transformed in formula, otherwise, untransformed variables are returned.

envir

environment in which the formula will be evaluated

...

further arguments such as data, weight, subset, offset used to create extra columns in the resulting data.frame, with names between dots such as '".offset."'

Value

For getvarnames: names of all variables (transformed=FALSE) or simple terms (transformed=TRUE), including the attributes

xvar

those from the right hand side of the formula

yvar

left hand side, if present

yvar

conditioning part, denoted after a | symbol in formula, if applicable

For getvariables: data.frame containing the extracted variables or simple terms, with the attributes of getvarnames

Author(s)

Werner A. Stahel

See Also

model.frame, get_all_vars

Examples

data(d.blast)
getvarnames(log10(tremor)~log10(distance)*log10(charge), data=d.blast)

dd <- getvariables(log10(tremor)~log10(distance)*log10(charge),
                   data=d.blast, by=location)
str(dd)

plgraphics documentation built on Oct. 19, 2023, 3 p.m.