lsms-worldbank / susometa

Extracts data from Survey Solutions' questionnaire and other metadata.
Other
0 stars 0 forks source link

Allow format of answer options to be specified #12

Open arthur-shaw opened 3 weeks ago

arthur-shaw commented 3 weeks ago

When the function was first created, the main use case was to label columns in a gt table. Hence, the function returned a named character vector where the names are a combination of the variable name in Designer and of the values.

Examples:

c(s07Bq02_cereales__1 = "Riz local type 1", s07Bq02_cereales__2 = "Riz local type 2", 
s07Bq02_cereales__3 = "Riz importé 1", s07Bq02_cereales__4 = "Riz importé 2", 
s07Bq02_cereales__5 = "Riz importé 3", s07Bq02_cereales__6 = "Maïs en épi", 
s07Bq02_cereales__7 = "Maïs en grain", s07Bq02_cereales__8 = "Mil", 
s07Bq02_cereales__9 = "Sorgho", s07Bq02_cereales__10 = "Blé", 
s07Bq02_cereales__11 = "Fonio", s07Bq02_cereales__12 = "Autres céréales", 
s07Bq02_cereales__13 = "Farine de maïs", s07Bq02_cereales__14 = "semoule de mais", 
s07Bq02_cereales__15 = "Farine de mil", s07Bq02_cereales__16 = "Semoule de mil", 
s07Bq02_cereales__17 = "Farine de blé locale ou importée", 
s07Bq02_cereales__18 = "Semoule de blé", s07Bq02_cereales__19 = "Autres farines de céréales", 
s07Bq02_cereales__20 = "Autres semoules de céréales", s07Bq02_cereales__21 = "Macaroni", 
s07Bq02_cereales__22 = "Spaghettis", s07Bq02_cereales__23 = "Autres pâtes alimentaires", 
s07Bq02_cereales__24 = "Pain moderne type 1", s07Bq02_cereales__25 = "Pain moderne type 2", 
s07Bq02_cereales__26 = "Pain traditionnel type 1", s07Bq02_cereales__27 = "Pains traditionnel type 2", 
s07Bq02_cereales__28 = "Céréales de petit déjeuner", s07Bq02_cereales__29 = "Croissants", 
s07Bq02_cereales__30 = "Biscuits", s07Bq02_cereales__31 = "Gâteaux", 
s07Bq02_cereales__32 = "Beignets, galettes")

But another important use case is to return the value labels in the form for labelling with {haven}, {labelled}, etc.

To have the same function provide a return value in a different form, add a parameter to specify the desired form, with the more frequent use case potentially being default value.