one_hot: Model matrix with one-hot encoding for unordered factors

View source: R/one_hot.R

one_hotR Documentation

Model matrix with one-hot encoding for unordered factors

Description

This replicates model.matrix() but with one-hot encoding for unordered factors. Ordered factors use the default contrasts (as set in options("contrasts"). By default, the first column of the model matrix (the intercept) is removed.

Usage

one_hot(formula, data, intercept = FALSE)

Arguments

formula

A model formula passed to model.matrix().

data

A data frame passed to model.matrix().

intercept

If FALSE (the default) then the first column of the matrix is removed before returning/ If TRUE then the returned matrix is unaffected.

Details

The contrast function used is contrast_one_hot().

Value

A matrix (as from model.matrix()).


jedwards24/jemodel documentation built on July 1, 2023, 3:59 p.m.