ordered(x, ...) is.ordered(x) as.ordered(x)
x | data to be made into an ordered factor. |
... | one or more appropriate object(s). |
ordered | returns an ordered factor: that is, an object of class c("ordered", "factor"). |
is.ordered | returns TRUE if x inherits from class "ordered"; otherwise, it returns FALSE. |
as.ordered | returns x if x is ordered; otherwise, it returns ordered(x). |
color <- c("red", "blue", "green", "white", "black") colors <- ordered(color) colors # [1] red blue green white black # Levels: black < blue < green < red < white
class(colors) # [1] "ordered" "factor"
is.ordered(colors) # [1] TRUE
colors <- as.ordered(color) colors # [1] red blue green white black # Levels: black < blue < green < red < white