Skip to content

Commit 1130172

Browse files
committed
move filters; add wave 12 experimental field
1 parent 9cc1f3f commit 1130172

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

facebook/qsf-tools/generate-codebook.R

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

facebook/qsf-tools/static/static_microdata_fields.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ UserLanguage,NA,"survey language",NA,NA,NA,NA
66
fips,NA,"county FIPS code",NA,NA,NA,NA
77
weight,NA,"Facebook respondent weight",NA,NA,NA,NA
88
module,NA,"question set respondent was assigned to",NA,NA,NA,NA
9+
w12_treatment,NA,"experimental treatment respondent was assigned to",NA,NA,NA,NA

0 commit comments

Comments
 (0)