category(x, levels=<<see below>>, labels=as.character(levels), ordered=F, exclude=NULL) is.category(x) as.category(x)
is.category returns TRUE if x is a category object (has "levels"), and returns FALSE otherwise.
as.category returns x, if x is a category, category(x) otherwise.
category(occupation) # "doctor", "lawyer", etc.category(occupation, exclude=NA) # NAs in the vector rather than a level for NAs
# make readable labels occ <- category(occupation,level=c("d","l"), label=c("Doctor","Lawyer"))
# turn category into character vector occ.char <- levels(occ)[occ]
colors <- category(color,c("red","green","blue")) table(colors) #table counting occurrences of colors