In contrast to the default behaviour of as.factor, this function uses the unsorted unique values of x as levels and not sorted unique values.

toFactor(x)

Arguments

x

vector to be converted to factor

Examples

x <- c("b", "c", "a") as.factor(x) # Levels: a b c
#> [1] b c a #> Levels: a b c
toFactor(x) # Levels: b c a
#> [1] b c a #> Levels: b c a