factor2ind: Make An Integer Matrix Out of A Factor Variable.

View source: R/factor2ind.R

factor2indR Documentation

Make An Integer Matrix Out of A Factor Variable.

Description

Create an indicator matrix of dimension length(x) x (nlevels(x)-1) with the column corresponding to the baseline level removed (by default the first level is used as baseline).

Usage

factor2ind(x, baseline)

Arguments

x

a variable.

baseline

a string indicating the reference level.

Value

a matrix

Examples

x = gl(4, 2, labels = c( "A", "B", "C", "D"))
factor2ind(x)
factor2ind(x, "C")

SophiaJia/Survout documentation built on Oct. 1, 2022, 9:52 p.m.