Generates Class Indicator Matrix from a Factor

Usage

class.ind(cl)

Arguments

cl factor or vector of classes for cases.

Description

Generates a class indicator function from a given factor.

Value

a matrix which is zero except for the column corresponding to the class.

Examples

# The function is currently defined as
function(cl)
{
  n <- length(cl)
  cl <- as.factor(cl)
  x <- matrix(0, n, length(levels(cl)))
  x[(1:n) + n * (codes(cl) - 1)] <- 1
  dimnames(x) <- list(row.names(cl), levels(cl))
  x
}


[Package Contents]