contrast_one_hot: Contrast function for one-hot encodings

View source: R/one_hot.R

contrast_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

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

Arguments

n

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

contrasts

Only the default of TRUE is supported.

sparse

Only the default of FALSE is supported.

Details

Only intended to be used in one_hot(). Copy of hardhat:::contr_one_hot().

Value

A diagonal matrix that is n-by-n.


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