contr_one_hot: Contrast function for one-hot encodings

Description Usage Arguments Value

View source: R/model-matrix.R

Description

This contrast function produces a model matrix that has indicator columns for each level of each factor.

Usage

1

Arguments

n

A vector of character factor levels or the number of unique levels.

contrasts

This argument is for backwards compatibility and only the default of TRUE is supported.

sparse

This argument is for backwards compatibility and only the default of FALSE is supported.

Value

A diagonal matrix that is n-by-n.


DavisVaughan/hardhat documentation built on Oct. 5, 2021, 9:53 a.m.