@@ -170,6 +170,7 @@ load_response_one <- function(input_filename, params, contingency_run) {
170170 input_data <- bodge_v4_translation(input_data , wave )
171171 input_data <- bodge_C6_C8(input_data , wave )
172172 input_data <- bodge_B13(input_data , wave )
173+ input_data <- bodge_E1(input_data , wave )
173174
174175 input_data <- code_symptoms(input_data , wave )
175176 input_data <- code_hh_size(input_data , wave )
@@ -486,6 +487,34 @@ bodge_B13 <- function(input_data, wave) {
486487 return (input_data )
487488}
488489
490+ # ' Fix E1_* names in Wave 11 data after ~June 16, 2021.
491+ # '
492+ # ' Items E1_1 through E1_4 are part of a matrix. Qualtrics, for unknown reasons,
493+ # ' switched to naming these E1_4 through E1_7 in June. Convert back to the
494+ # ' intended names.
495+ # '
496+ # ' @param input_data data frame of responses, before subsetting to select
497+ # ' variables
498+ # ' @param wave integer indicating survey version
499+ # '
500+ # ' @return corrected data frame
501+ # ' @importFrom dplyr rename
502+ bodge_E1 <- function (input_data , wave ) {
503+ E14_present <- all(c(" E1_1" , " E1_2" , " E1_3" , " E1_4" ) %in% names(input_data ))
504+ E47_present <- all(c(" E1_4" , " E1_5" , " E1_6" , " E1_7" ) %in% names(input_data ))
505+ assert(! (E14_present && E47_present ), " fields E1_1-E1_4 should not be present at the same time as fields E1_4-E1_7" )
506+
507+ if ( E47_present ) {
508+ input_data <- rename(input_data ,
509+ E1_1 = " E1_4" ,
510+ E1_2 = " E1_5" ,
511+ E1_3 = " E1_6" ,
512+ E1_4 = " E1_7"
513+ )
514+ }
515+ return (input_data )
516+ }
517+
489518# ' Process module assignment column.
490519# '
491520# ' Rename `module` and recode to A/B/`NA`. Note: module assignment column name
0 commit comments