.BG
.FN category
.FN is.category
.FN as.category
.TL
Create Category from Discrete Data
.CS
category(x, levels=unique(x),
         labels=as.character(levels))
is.category(x)
as.category(x)
.AG x
data vector.  Missing values (`NA's) are allowed.
.AG levels
optional vector of levels for the category.
Any data value that does not match a value in `levels' is
coded in the output vector as `NA'.
Missing values (`NA's) are allowed.
.AG labels
optional vector of values to use as labels for the levels of
the category.
.RT
vector with `levels' attribute, indicating which level the
category takes on for each data value.
Think of the return value as a subscript into the `levels'
attribute.
.Co NA s
indicate places where a data value in
`x' does not match any value in `levels'.
.PP
`is.category' returns `TRUE' if `x' is a category object, `FALSE' otherwise.
.PP
`as.category' returns `x', if `x' is a category, `category(x)' otherwise.
.SA
`table' and `tapply' for common computations using categories.
.EX
category(occupation)  # "doctor", "lawyer", etc.

# make readable labels
occ <- category(occupation,level=c("d","l"),
    label=c("Doctor","Lawyer"))

# turn category into character vector
levels(occ)[occ]

colors <- category(color,c("red","green","blue"))
table(colors)  #table counting occurrences of colors
.KW category
.KW classes
.WR
