Skip to content

Commit 271f702

Browse files
authored
Merge pull request #1431 from cmu-delphi/add-c7-inds
[CTIS] Add avoiding contact indicators to contingency tables
2 parents d50a2a5 + 4339087 commit 271f702

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

facebook/delphiFacebook/R/contingency_indicators.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ get_aggs <- function() {
8282
"pct_hh_cmnty_cli", "hh_community_yes", compute_binary, jeffreys_binary,
8383
"pct_nohh_cmnty_cli", "community_yes", compute_binary, jeffreys_binary,
8484
"pct_direct_contact", "c_direct_contact", compute_binary, jeffreys_binary,
85+
"pct_avoid_contact", "c_avoid_contact", compute_binary, jeffreys_binary,
86+
"pct_avoid_contact_7d", "c_avoid_contact_7d", compute_binary, jeffreys_binary,
8587

8688
# symptoms
8789
"pct_symp_fever", "symp_fever", compute_binary, jeffreys_binary,

facebook/delphiFacebook/R/contingency_variables.R

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,6 +1080,36 @@ code_behaviors <- function(input_data, wave) {
10801080
} else {
10811081
input_data$c_direct_contact <- NA
10821082
}
1083+
1084+
# avoid_contact
1085+
# Percentage of respondents that have reported having intentionally avoided
1086+
# contact with other people all or most of the time
1087+
# 1 = all of the time, 2 = most of the time, 3 = some of the time,
1088+
# 4 = none of the time
1089+
if ("C7" %in% names(input_data)) {
1090+
input_data$c_avoid_contact <- case_when(
1091+
input_data$C7 %in% c(1, 2) ~ 1,
1092+
input_data$C7 %in% c(3, 4) ~ 0,
1093+
TRUE ~ NA_real_
1094+
)
1095+
} else {
1096+
input_data$c_avoid_contact <- NA_real_
1097+
}
1098+
1099+
# avoid_contact_7d
1100+
# Percentage of respondents that have reported having intentionally avoided
1101+
# contact with other people all or most of the time in the last 7 days
1102+
# 1 = all of the time, 2 = most of the time, 3 = some of the time,
1103+
# 4 = a little of the time, 5 = none of the time
1104+
if ("C7a" %in% names(input_data)) {
1105+
input_data$c_avoid_contact_7d <- case_when(
1106+
input_data$C7a %in% c(1, 2) ~ 1,
1107+
input_data$C7a %in% c(3, 4, 5) ~ 0,
1108+
TRUE ~ NA_real_
1109+
)
1110+
} else {
1111+
input_data$c_avoid_contact_7d <- NA_real_
1112+
}
10831113

10841114
return(input_data)
10851115
}

0 commit comments

Comments
 (0)