mnoetel / READI-SCRUB

For READI SCRUB project cleaning code and dashboard
Creative Commons Zero v1.0 Universal
1 stars 1 forks source link

Checkbox question attributes missing #13

Closed mnoetel closed 4 years ago

mnoetel commented 4 years ago

Somewhere between cleaning boxes and merging to saved attributes all the attributes for the boxes disappear

saved_attributes$w4_wkex_trans_int_9 d6_boxes$w4_wkex_trans_int_9

aksaeri commented 4 years ago

Note this is not only the checkbox attributes; lots of attributes are missing - e.g.,

str(d$gender)
 Factor w/ 3 levels "Male","Female",..: 2 2 2 2 1 2 2 2 1 2 ...
aksaeri commented 4 years ago

I have used sjlabelled::copy_labels if the variable names are the same, because sometimes subsetting or otherwise manipulating the data removes the labels.

d$gender <- set_label(d$gender, "Gender")
> str(d$gender)
 Factor w/ 3 levels "Male","Female",..: 2 2 2 2 1 2 2 2 1 2 ...
 - attr(*, "label")= chr "Gender"
> d_wave3 <- d %>% filter(wave == 3)
> str(d_wave3$gender)
Factor w/ 3 levels "Male","Female",..: 2 2 2 2 1 2 2 2 1 2 ...
> d_wave3 <- d_wave3 %>% copy_labels(d)
> str(d_wave3$gender)
 Factor w/ 3 levels "Male","Female",..: 2 2 2 2 1 2 2 2 1 2 ...
 - attr(*, "label")= chr "Gender"
mnoetel commented 4 years ago

Thanks Zan, part of the problem was dplyr was out of date and filter removed labels. Most vars now have labels: names(d)[null_attributes] [1] "beh_handwash" "origin" "wave" "info_need_symptoms"
[5] "info_need_stories" "info_need_science" "info_need_actions" "info_need_risk_group"
[9] "info_need_education" "info_need_travel" "info_need_my_risk" "info_need_testing"
[13] "info_need_none" "manip_check_info" "manip_check_safe" "manip_check_no_safe"
[17] "manip_check_aut" "manip_check_cont" "aut_int" "safe_int"
[21] "autonomy_manip_check_passed" "safety_manip_check_passed" "state_aus" "region_aus"
[25] "region_aus_type" "will_you_stand_against_corona" "condition" "pledge_wash"
[29] "pledge_sneeze" "pledge_face" "pledge_2m" "pledge_distancing"
[33] "pledge_sum" "agegroup"