Revision: 27812
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at June 24, 2010 07:43 by ascidiacea
Initial Code
# x is already a factor
levels(x)
# [1] "Large" "Medium" "Small"
# various ways to reorder levels to be Small, Medium, Large
factor(x, levels = levels(x)[3:1])
factor(x, levels = c("Small", "Medium", "Large"))
# x is not yet a factor (e.g., a character vector or data.frame col)
factor(x, levels = levels(factor(x))[3:1])
factor(x, levels = c("Small", "Medium", "Large"))
Initial URL
Initial Description
Initial Title
Reorder levels of a factor
Initial Tags
Initial Language
R