as_model_matrix: Transform a data frame

Description Usage Arguments Value Examples

View source: R/utils.R

Description

Transform a data frame into a matrix using one hot encoding.

Usage

1
as_model_matrix(df, intercept = FALSE)

Arguments

df

A data frame.

intercept

Whether to have a column with all 1s. Default is FALSE.

Value

A matrix.

Examples

1
2
mat <- as_model_matrix(iris)
str(mat)

bigutilsr documentation built on April 14, 2021, 1:06 a.m.