Learn R Programming

multiblock (version 0.8.8.2)

dummycode: 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)

Value

matrix made by dummy-coding the input vector.

Arguments

Y

vector to dummy code.

contrast

Contrast type, default = "contr.sum".

drop

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

Examples

Run this code
vec <- c("a","a","b","b","c","c")
dummycode(vec)

Run the code above in your browser using DataLab