Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

model_matrix

Construct a design matrix


Description

This is a thin wrapper around stats::model.matrix() which returns a tibble. Use it to determine how your modelling formula is translated into a matrix, an thence into an equation.

Usage

model_matrix(data, formula, ...)

Arguments

data

A data frame

formula

A modelling formula

...

Other arguments passed onto stats::model.matrix()

Value

A tibble.

Examples

model_matrix(mtcars, mpg ~ cyl)
model_matrix(iris, Sepal.Length ~ Species)
model_matrix(iris, Sepal.Length ~ Species - 1)

modelr

Modelling Functions that Work with the Pipe

v0.1.8
GPL-3
Authors
Hadley Wickham [aut, cre], RStudio [cph]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.