Order 'quasinumerical' categorical vectors (increasing order)
orderQuasinum.Rd
A function to order 'quasinumerical' (i.e. categorical with values such as "15-30" or "<18") integer vectors into increasing order. Currently handles away the following non-numerical characters "-", ">", "<", ">=", "<=", "+".
See also
Used in getAgeGender
and plotAgeGender
/ plotAge
Examples
age1 <- c("<1", "1-15", "16-25", ">65", "26-65")
age2 <- c("0-4", "5-10", ">65", "25-64", "11-25")
age3 <- c("5-10", ">65", "25-64", "11-25", "<=4")
age4 <- c(">=65", "<18", "18-64")
age5 <- c("5-10", "+65", "25-64", "11-25", "0-4")
age1
#> [1] "<1" "1-15" "16-25" ">65" "26-65"
orderQuasinum(age1)
#> [1] "<1" "1-15" "16-25" "26-65" ">65"
age2
#> [1] "0-4" "5-10" ">65" "25-64" "11-25"
orderQuasinum(age2)
#> [1] "0-4" "5-10" "11-25" "25-64" ">65"
age3
#> [1] "5-10" ">65" "25-64" "11-25" "<=4"
orderQuasinum(age3)
#> [1] "<=4" "5-10" "11-25" "25-64" ">65"
age4
#> [1] ">=65" "<18" "18-64"
orderQuasinum(age4)
#> [1] "<18" "18-64" ">=65"
age5
#> [1] "5-10" "+65" "25-64" "11-25" "0-4"
orderQuasinum(age5)
#> [1] "0-4" "5-10" "11-25" "25-64" "+65"