Will convert even a mixed character vector (combining numbers and text) of education levels 10 and 4 to a factor.

edu_factorise(x, levels)

edu4_factorise(x)

edu9_factorise(x)

Arguments

x

character vector

levels

levels returned from the edu_levels() function

Value

factor

Details

Specialized returns

  • edu_factorise - with option to choose number of levels

  • edu4_factorise - directly transform vector coded in 4-level scheme

  • edu9_factorise - directly transform vector coded in 9-levels scheme

See also

Examples


edu9 <- c("7", "7", "8", NA, "Primary school (6 years)", "5", "9")
edu_factorise(edu9, 9)
#> [1] Lower level University/University college degree (16 years)
#> [2] Lower level University/University college degree (16 years)
#> [3] Upper level University/University college (19 years)       
#> [4] <NA>                                                       
#> [5] Primary school (6 years)                                   
#> [6] High school diploma (13 years)                             
#> [7] Ph.D. (21 years)                                           
#> 9 Levels: Pre-school/No schooling ... Ph.D. (21 years)
#> Numeric levels: 0 6 9 12 13 14 16 19 21 
edu9_factorise(edu9)
#> [1] Lower level University/University college degree (16 years)
#> [2] Lower level University/University college degree (16 years)
#> [3] Upper level University/University college (19 years)       
#> [4] <NA>                                                       
#> [5] Primary school (6 years)                                   
#> [6] High school diploma (13 years)                             
#> [7] Ph.D. (21 years)                                           
#> 9 Levels: Pre-school/No schooling ... Ph.D. (21 years)
#> Numeric levels: 0 6 9 12 13 14 16 19 21