ordered
Create an Ordered factor Object

Description

Return an object with class ordered and class factor.

Usage

ordered(x, ...)
is.ordered(x)
as.ordered(x)

Arguments

x data to be made into an ordered factor.
... one or more appropriate object(s).
Value
orderedreturns an ordered factor: that is, an object of class c("ordered", "factor").
is.orderedreturns TRUE if x inherits from class "ordered"; otherwise, it returns FALSE.
as.orderedreturns x if x is ordered; otherwise, it returns ordered(x).
See Also
factor,levels
Examples

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

Package base version 4.0.0-28
Package Index