Parse a Formula and Create a Model Frame
Create a model frame for a formula object, by handling the left hand side the same way the right hand side is handled in model.frame. Especially variables separated by + are interpreted as separate variables.
ParseFormula(formula, data = parent.frame(), drop = TRUE)
formula |
an object of class "formula" (or one that can be coerced to that class): a symbolic description for the variables to be described. |
data |
an optional data frame, list or environment (or object coercible by as.data.frame to a data frame) containing the variables in the model. If not found in data, the variables are taken from environment(formula), typically the environment from which lm is called. |
drop |
if |
This is used by Desc.formula
for describing data by groups while remaining flexible for using
I(...)
constructions, functions or interaction terms.
a list of 3 elements
formula |
the formula which had to be parsed |
lhs |
a list of 3 elements: |
rhs |
a list of 3 elements: |
Andri Signorell <andri@signorell.net>
The functions used to handle formulas: model.frame
, terms
, formula
Used in: Desc.formula
set.seed(17) piz <- d.pizza[sample(nrow(d.pizza),10), c("temperature","price","driver","weekday")] f1 <- formula(. ~ driver) f2 <- formula(temperature ~ .) f3 <- formula(temperature + price ~ .) f4 <- formula(temperature ~ . - driver) f5 <- formula(temperature + price ~ driver) f6 <- formula(temperature + price ~ driver * weekday) f7 <- formula(I(temperature^2) + sqrt(price) ~ driver + weekday) f8 <- formula(temperature + price ~ 1) f9 <- formula(temperature + price ~ driver * weekday - price) ParseFormula(f1, data=piz) ParseFormula(f2, data=piz) ParseFormula(f3, data=piz) ParseFormula(f4, data=piz) ParseFormula(f5, data=piz) ParseFormula(f6, data=piz) ParseFormula(f7, data=piz) ParseFormula(f8, data=piz)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.