dummycode: Dummy-coding of a single vector

View source: R/utilities.R

dummycodeR Documentation

Dummy-coding of a single vector

Description

Flexible dummy-coding allowing for all R's built-in types of contrasts and optional dropping of a factor level to reduce rank defficiency probability.

Usage

dummycode(Y, contrast = "contr.sum", drop = TRUE)

Arguments

Y

vector to dummy code.

contrast

Contrast type, default = "contr.sum".

drop

logical indicating if one level should be dropped (default = TRUE).

Value

matrix made by dummy-coding the input vector.

Examples

vec <- c("a","a","b","b","c","c")
dummycode(vec)

multiblock documentation built on Nov. 18, 2023, 5:06 p.m.