Skip to contents

This labeling function ia function factory - https://adv-r.hadley.nz/function-factories.html The output of this function is actually a function

Usage

label_choiceset(dico, x)

Arguments

dico

An object of the "kobodico" class format as defined in kobocruncher

x

variable

Examples

dico <- kobo_dico( xlsformpath = system.file("sample_xlsform.xlsx", package = "kobocruncher") )
datalist <- kobo_data(datapath = system.file("data.xlsx", package = "kobocruncher") )

data <- kobo_frame(datalist = datalist,
                   dico = dico,
                   var = "profile.country"   )

label_choiceset(dico = dico, 
                x="profile.country")(data$profile.country)
#>           VEN           HND           SLV           SLV           COL 
#>   "Venezuela"    "Honduras" "El Salvador" "El Salvador"    "Colombia" 

## Test when there's no dictionnary
data$profile.occupation
#> [1] "Consultant" "farmer"     "vendor"     "teacher"    "farmer"    
label_choiceset(dico = dico, 
                x="profile.occupation")(data$profile.occupation)
#>         <NA>         <NA>         <NA>         <NA>         <NA> 
#> "Consultant"     "farmer"     "vendor"    "teacher"     "farmer" 


label_choiceset(dico = dico, 
                x="profile.occupation")(data$profile.occupation)
#>         <NA>         <NA>         <NA>         <NA>         <NA> 
#> "Consultant"     "farmer"     "vendor"    "teacher"     "farmer"