EVOLUTION-MANAGER
Edit File: class.ind.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Generates Class Indicator Matrix from a Factor</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for class.ind {nnet}"><tr><td>class.ind {nnet}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2> Generates Class Indicator Matrix from a Factor </h2> <h3>Description</h3> <p>Generates a class indicator function from a given factor. </p> <h3>Usage</h3> <pre> class.ind(cl) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>cl</code></td> <td> <p>factor or vector of classes for cases. </p> </td></tr></table> <h3>Value</h3> <p>a matrix which is zero except for the column corresponding to the class. </p> <h3>References</h3> <p>Venables, W. N. and Ripley, B. D. (2002) <em>Modern Applied Statistics with S.</em> Fourth edition. Springer. </p> <h3>Examples</h3> <pre> # 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 } </pre> <hr /><div style="text-align: center;">[Package <em>nnet</em> version 7.3-12 <a href="00Index.html">Index</a>]</div> </body></html>