Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

class.ind

Generates Class Indicator Matrix from a Factor


Description

Generates a class indicator function from a given factor.

Usage

class.ind(cl)

Arguments

cl

factor or vector of classes for cases.

Value

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

References

Venables, W. N. and Ripley, B. D. (2002) Modern Applied Statistics with S. Fourth edition. Springer.

Examples

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

nnet

Feed-Forward Neural Networks and Multinomial Log-Linear Models

v7.3-16
GPL-2 | GPL-3
Authors
Brian Ripley [aut, cre, cph], William Venables [cph]
Initial release
2021-04-17

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.