@@ -326,7 +326,7 @@ process_qsf <- function(path_to_qsf,
326326
327327 if (any(is.na(qdf $ description ))) {
328328 nonlabelled_items <- qdf $ variable [is.na(qdf $ description )]
329- stop(sprintf(" items %s do not have a short name assigned " ,
329+ stop(sprintf(" items %s do not have a description provided " ,
330330 paste(nonlabelled_items , collapse = " , " ))
331331 )
332332 }
@@ -396,7 +396,14 @@ add_static_fields <- function(codebook,
396396 path_to_static_fields = " ./static/static_microdata_fields.csv" ) {
397397 static_fields <- get_static_fields(wave , path_to_static_fields )
398398
399- return (bind_rows(codebook , static_fields ))
399+ codebook <- bind_rows(codebook , static_fields ) %> %
400+ filter(! (variable == " module" & wave < 11 ), # module field is only available for wave >= 11
401+ ! (variable %in% c(" wave" , " UserLanguage" , " fips" ) & wave < 4 ), # wave, UserLangauge, and fips fields are only available for wave >= 4
402+ ! (variable == " w12_treatment" & wave == 12.5 ), # experimental arm field is only available for wave == 12.5
403+ variable != " Random_Number"
404+ )
405+
406+ return (codebook )
400407}
401408
402409# ' Load dataframe of non-Qualtrics data fields
@@ -417,8 +424,7 @@ get_static_fields <- function(wave,
417424 response_option_randomization = col_character()
418425 )) %> %
419426 mutate(wave = wave ) %> %
420- select(wave , everything()) %> %
421- filter(! (variable == " module" & wave < 11 ))
427+ select(wave , everything())
422428
423429 return (static_fields )
424430}
0 commit comments