### Name: factor ### Title: Factors ### Aliases: factor ordered is.factor is.ordered as.factor as.ordered ### is.na<-.factor Math.factor Ops.factor Summary.factor Ops.ordered ### addNA ### Keywords: category NA ### ** Examples (ff <- factor(substring("statistics", 1:10, 1:10), levels=letters)) as.integer(ff) # the internal codes factor(ff) # drops the levels that do not occur ff[, drop=TRUE] # the same, more transparently factor(letters[1:20], labels="letter") class(ordered(4:1)) # "ordered", inheriting from "factor" ## suppose you want "NA" as a level, and to allow missing values. (x <- factor(c(1, 2, NA), exclude = NULL)) is.na(x)[2] <- TRUE x # [1] 1 is.na(x) # [1] FALSE TRUE FALSE ## Using addNA() Month <- airquality$Month table(addNA(Month)) table(addNA(Month, ifany=TRUE))