Skip to content

Commit ff69ef4

Browse files
authored
Merge pull request #1630 from cmu-delphi/ndefries/changelog-from-codebook
[CTIS QSF tools] Generate changelog from diffing codebook
2 parents 05d8e0c + ccb5f91 commit ff69ef4

File tree

4 files changed

+412
-399
lines changed

4 files changed

+412
-399
lines changed

facebook/qsf-tools/combine_changelogs_eu.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ combine_changelogs <- function(path_to_changelog_eu,
2222
old_version = col_double()
2323
)) %>%
2424
mutate(
25-
eu_version = "EU"
25+
eu_noneu = "EU"
2626
)
2727

2828
changelog_noneu <- read_csv(path_to_changelog_noneu, col_types = cols(
@@ -31,21 +31,21 @@ combine_changelogs <- function(path_to_changelog_eu,
3131
old_version = col_double()
3232
)) %>%
3333
mutate(
34-
eu_version = "Non-EU"
34+
eu_noneu = "Non-EU"
3535
)
3636

3737
# Using rbind here to raise an error if columns differ between the existing
3838
# changelog and the new wave data.
3939
changelog_with_duplicates <- rbind(changelog_eu, changelog_noneu)
4040

41-
count_duplicated_rows <- changelog_with_duplicates %>% group_by(across(c(-eu_version))) %>% summarize(count = n())
41+
count_duplicated_rows <- changelog_with_duplicates %>% group_by(across(c(-eu_noneu))) %>% summarize(count = n())
4242
changelog <- changelog_with_duplicates %>% left_join(count_duplicated_rows)
43-
changelog$eu_version[changelog$count == 2] <- "Both"
43+
changelog$eu_noneu[changelog$count == 2] <- "Both"
4444

4545
# Sort so that items with missing type (non-Qualtrics fields) are at the top.
4646
# Drop duplicates.
4747
changelog <- changelog %>%
48-
arrange(variable_name, eu_version) %>%
48+
arrange(variable_name, eu_noneu) %>%
4949
select(-count) %>%
5050
distinct()
5151

facebook/qsf-tools/combine_codebooks_eu.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,30 @@ combine_codebooks <- function(path_to_codebook_eu,
2121
version = col_double()
2222
)) %>%
2323
mutate(
24-
eu_version = "EU"
24+
eu_noneu = "EU"
2525
)
2626

2727
codebook_noneu <- read_csv(path_to_codebook_noneu, col_types = cols(
2828
.default = col_character(),
2929
version = col_double()
3030
)) %>%
3131
mutate(
32-
eu_version = "Non-EU"
32+
eu_noneu = "Non-EU"
3333
)
3434

3535
# Using rbind here to raise an error if columns differ between the existing
3636
# codebook and the new wave data.
3737
codebook_with_duplicates <- rbind(codebook_eu, codebook_noneu)
3838

39-
count_duplicated_rows <- codebook_with_duplicates %>% group_by(across(c(-eu_version))) %>% summarize(count = n())
39+
count_duplicated_rows <- codebook_with_duplicates %>% group_by(across(c(-eu_noneu))) %>% summarize(count = n())
4040
codebook <- codebook_with_duplicates %>% left_join(count_duplicated_rows)
41-
codebook$eu_version[codebook$count == 2] <- "Both"
41+
codebook$eu_noneu[codebook$count == 2] <- "Both"
4242

4343
# Sort so that items with missing type (non-Qualtrics fields) are at the top.
4444
# Drop duplicates.
4545
codebook <- codebook %>%
46-
arrange(!is.na(.data$question_type), variable, version, eu_version) %>%
47-
select(-count) %>%
46+
arrange(!is.na(.data$question_type), variable, version, eu_noneu) %>%
47+
select(-count, -replaces) %>%
4848
distinct()
4949

5050
return(codebook)

0 commit comments

Comments
 (0)