model.data: Reconstruct data from a linear model

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/contour-lm.R

Description

Create a data frame with just the variables in the formula in a lm object. This is comparable to model.matrix or model.frame except that factors, polynomials, transformations, etc. are not expanded.

Usage

1
model.data(lmobj, lhs = FALSE)

Arguments

lmobj

An object returned by lm or one of its relatives.

lhs

Boolean indicator of whether or not to include the variable(s) on the left-hand side of the model formula.

Details

This is an easy-to-use substitute for get_all_vars. The formula, data, and subset arguments, if present in lmobj's call, affect the result appropriately.

Value

A data frame containing each of the variables referenced in the model formula.

Author(s)

Russell V. Lenth

References

Lenth RV (2009) “Response-Surface Methods in R, Using rsm”, Journal of Statistical Software, 32(7), 1–17. http://www.jstatsoft.org/v32/i07/.

See Also

model.matrix, model.frame

Examples

1
2
3
4
library(rsm)
trees.lm <- lm(log(Volume) ~ poly(log(Girth),3), data = trees, subset = 1:20)
model.frame(trees.lm)
model.data(trees.lm)

rvlenth/rsm documentation built on Sept. 2, 2018, 10:06 a.m.