Learn R Programming

survout (version 0.1.0)

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

Value

a matrix

Arguments

x

a variable.

baseline

a string indicating the reference level.

Examples

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

Run the code above in your browser using DataLab