Rev 25384 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
\name{codes-deprecated}\alias{codes-deprecated}\title{Factor Codes}\description{This (generic) function returns a numeric coding of a factor. It canalso be used to assign to a factor using the coded form.It is now \code{\link{Deprecated}}.}\usage{codes(x, \dots)codes(x, \dots) <- value}\arguments{\item{x}{an object from which to extract or set the codes.}\item{\dots}{further arguments passed to or from other methods.}\item{value}{replacement value.}}\value{For an ordered factor, it returns the internal coding (1 for thelowest group, 2 for the second lowest, etc.).For an unordered factor, an alphabetical ordering of the levels isassumed, i.e., the level that is coded 1 is the one whose name issorted first according to the prevailing collating sequence.\bold{Warning:} the sort order may well depend on the locale, andshould not be assumed to be ASCII.}\note{Normally \code{codes} is not the appropriate function to use with anunordered factor. Use \code{\link{unclass}} or\code{\link{as.numeric}} to extract the codes used in the internalrepresentation of the factor, as these do not assume that the codesare sorted.The behaviour for unordered factors is dubious, but compatible with Sversion 3. To get the internal coding of a factor, use\code{\link{as.integer}}. Note in particular that the codes may notbe the same in different language locales because of collatingdifferences.}\seealso{\code{\link{factor}}, \code{\link{levels}}, \code{\link{nlevels}}.}\examples{\dontrun{codes(rep(factor(c(20,10)),3))x <- gl(3,5)codes(x)[3] <- 2xdata(esoph)( ag <- esoph$alcgp[12:1] )codes(ag)codes(factor(1:10)) # BEWARE!}}\keyword{category}\keyword{classes}