model_as_xy: Convert data frame and model 'formula' to input matrix and...

Description Usage Arguments Details Value See Also Examples

Description

Convert a data frame and model formula to a list containing the input variables as a matrix x and the output variable as a vector y. These structures are commonly used by various modelling functions such as glmnet.

Usage

1

Arguments

data

A data frame

formula

A formula

Details

All operators made available by formula are allowed.

Value

Two-element list containing input variables as a matrix x, and output variable as a vector y

See Also

formula model.matrix

Examples

1
2
3
4
model_as_xy(mtcars, hp ~ mpg)
model_as_xy(mtcars, hp ~ .)
model_as_xy(mtcars, hp ~ mpg * hp)
model_as_xy(mtcars, ~ .)

drsimonj/twidlr documentation built on May 15, 2019, 2:53 p.m.