This help topic is for R version 0.60. For the current version of R, try https://stat.ethz.ch/R-manual/R-patched/library/base/html/model.matrix.html
model.matrix {base}R Documentation

Construct design matrices

Description

Creates a design matrix from the description given in terms(formula), using the data in data which must contain columns with the same names as would be created by a call to model.frame(formula) or, more precisely, by evaluating attr(terms(formula), "variables"). There may be other columns and the order is not important.

Usage

model.matrix(formula =, data =)

Arguments

formula

A model formula or terms object

data

A data frame created with model.frame

Value

The design matrix for a regression model with the specified formula and data.

References

Chambers and Hastie: "Statistical Models in S"

See Also

model.frame, model.data.frame, terms

Examples

data(trees)
ff <- log(Volume) ~ log(Height) + log(Girth)
m <- model.frame(ff, trees)
mat <- model.matrix(ff, m)

[Package base version 0.60 ]