Section 7 Factor: Ordinal
7.1 Ordinal Factor
Example vector: x <- rep(c('L','M','H'), length=30)
Function | Explanation | Example |
---|---|---|
factor |
Make a vector to factor | factor(x=x, levels=c(L,M,H), labels=c(Low,Med,High)) |
as.factor |
Convert a vector to factor | as.factor(x) |
ordered |
Make a vector to an ordered factor | ordered(x=x, levels=c(L,M,H), labels=c(Low,Med,High)) |
as.ordered |
Convert a vector to ordered factor | as.ordered(x) |
levels |
Get the labels of the factor levels | levels(x) |
nlevels |
Get the number of levels of a factor | nlevels(x) |