contr_one_hot: Contrast function for one-hot encodings

View source: R/model-matrix.R

contr_one_hotR Documentation

Contrast function for one-hot encodings

Description

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

Usage

contr_one_hot(n, contrasts = TRUE, sparse = FALSE)

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.


hardhat documentation built on June 30, 2022, 5:05 p.m.