Create consent variable
- Variable
consent_coded
== 1
if respondents
answered “Yes, I agree” to question consent100
or
consent200
. consent_coded
== 0
indicates dropped off or not consent.
data <- data %>%
mutate(consent_coded = case_when(
consent100 == "Yes, I agree" | consent200 == "Yes, I agree" ~ 1,
TRUE ~ 0
))
data %>% count(consent_coded) %>%
kable("html", col.names=(c("Consent", "N"))) %>%
kable_styling(bootstrap_options = c("striped", "hover"))
- Consent timer variable is created to capture the first click
consent_first_click_coded
and last click
consent_last_click_coded
of the consent page in
seconds
data <- data %>%
mutate(consent_first_click_coded = coalesce(`consent100_timer_First Click`, `consent200_timer_First Click`)) %>%
mutate(consent_last_click_coded = coalesce(`consent100_timer_Last Click`, `consent200_timer_Last Click`))
# showing summary statistics of each variable
data %>%
select(consent_first_click_coded, consent_last_click_coded) %>%
summary() %>%
kable("html", col.names=(c("Consent First Click in sec", "Consent Last Click in sec"))) %>%
kable_styling(bootstrap_options = c("striped", "hover"))
|
Consent First Click in sec
|
Consent Last Click in sec
|
|
Min. : 0.647
|
Min. : 1.303
|
|
1st Qu.: 1.515
|
1st Qu.: 4.599
|
|
Median : 4.599
|
Median : 12.297
|
|
Mean : 19.467
|
Mean : 38.035
|
|
3rd Qu.: 11.464
|
3rd Qu.: 33.962
|
|
Max. :846.368
|
Max. :873.031
|
|
NA’s :1
|
NA’s :1
|
Create arm variable
Variable arm_coded
is created to identify the treatment
arm of the survey. It takes on two values: treatment_100
or
treatment_200
. If C1i_4
and C1i_5
or D1i_4
and D1i_5
are not empty, they are
assigned to arm_coded
== treatment_100
. If
C2i_4
and C2i_5
or D2i_4
and
D2i_5
are not empty, they are assigned to
arm_coded
== treatment_200
.
data <- data %>% mutate (arm_coded = case_when(
!is.na(C1i_4) & !is.na(C1i_5) | !is.na(D1i_4) & !is.na(D1i_5) ~ "treatment_100",
!is.na(C2i_4) & !is.na(C2i_5) | !is.na(D2i_4) & !is.na(D2i_5) ~ "treatment_200",
TRUE ~ ""
))
data %>% count(arm_coded) %>%
kable("html", col.names=(c("Arm", "N"))) %>%
kable_styling(bootstrap_options = c("striped", "hover"))
Arm
|
N
|
|
61
|
treatment_100
|
10
|
treatment_200
|
9
|
Variable acc_coded
is created to capture the
accountability question. acc_coded
== both
if
C1ii_1
and C1ii_4
or C2ii_1
and
C2ii_4
are not empty. acc_coded
==
some
if D1ii_1
and D1ii_2
or
D2ii_1
and D2ii_2
data <- data %>% mutate (acc_coded = case_when(
!is.na(C1ii_1) & !is.na(C1ii_4) | !is.na(C2ii_1) & !is.na(C2ii_4) ~ "both",
!is.na(D1ii_1) & !is.na(D1ii_2) | !is.na(D2ii_1) & !is.na(D2ii_2) ~ "some",
TRUE ~ ""
))
data %>% count(acc_coded) %>%
kable("html", col.names=(c("Accountability", "N"))) %>%
kable_styling(bootstrap_options = c("striped", "hover"))
Accountability
|
N
|
|
61
|
both
|
9
|
some
|
10
|
data %>% group_by(acc_coded) %>% count(arm_coded) %>%
kable("html", col.names=(c("Accountability", "Arm", "N"))) %>%
kable_styling(bootstrap_options = c("striped", "hover"))
Accountability
|
Arm
|
N
|
|
|
61
|
both
|
treatment_100
|
5
|
both
|
treatment_200
|
4
|
some
|
treatment_100
|
5
|
some
|
treatment_200
|
5
|
- Creating payment variable:
payself_first_coded
,
payother_first_coded
, payself_final_coded
,
payother_final_coded
data <- data %>%
mutate(payself_first_coded = coalesce(C1i_4, D1i_4, C2i_4, D2i_4)) %>%
mutate(payother_first_coded = coalesce(C1i_5, D1i_5, C2i_5, D2i_5)) %>%
mutate(payself_final_coded = coalesce(C1ii_1, D1ii_1, C2ii_1, D2ii_1)) %>%
mutate(payother_final_coded = coalesce(C1ii_4, D1ii_2, C2ii_4, D2ii_2))
- Double checking to see if added up to 100 or 200
data %>% filter(arm_coded == "treatment_100") %>% mutate(total_first = payself_first_coded + payother_first_coded) %>%
mutate(total_final = payself_final_coded + payother_final_coded) %>%
select(total_first, total_final) %>%
summary() %>%
kable("html", col.names=(c("Total First", "Total Final"))) %>%
kable_styling(bootstrap_options = c("striped", "hover"))
|
Total First
|
Total Final
|
|
Min. :100
|
Min. :100
|
|
1st Qu.:100
|
1st Qu.:100
|
|
Median :100
|
Median :100
|
|
Mean :100
|
Mean :100
|
|
3rd Qu.:100
|
3rd Qu.:100
|
|
Max. :100
|
Max. :100
|
data %>% filter(arm_coded == "treatment_200") %>% mutate(total_first = payself_first_coded + payother_first_coded) %>%
mutate(total_final = payself_final_coded + payother_final_coded) %>%
select(total_first, total_final) %>%
summary() %>%
kable("html", col.names=(c("Total First", "Total Final"))) %>%
kable_styling(bootstrap_options = c("striped", "hover"))
|
Total First
|
Total Final
|
|
Min. :200
|
Min. :200
|
|
1st Qu.:200
|
1st Qu.:200
|
|
Median :200
|
Median :200
|
|
Mean :200
|
Mean :200
|
|
3rd Qu.:200
|
3rd Qu.:200
|
|
Max. :200
|
Max. :200
|
- Creating different variables
data <- data %>%
mutate(payself_diff = payself_final_coded - payself_first_coded) %>%
mutate(payother_diff = payother_final_coded - payother_first_coded)
Create assist_text
variable
- Variable
assist_text_first_click_coded
and
assist_text_last_click_coded
are created to combine the
time first clicked and last clicked for both groups
data <- data %>%
mutate(assist_text_first_click_coded = coalesce(`assist_text100_timer_First Click`, `assist_text200_timer_First Click`)) %>%
mutate(assist_text_last_click_coded = coalesce(`assist_text100_timer_Last Click`, `assist_text100_timer_Last Click`))
data %>%
select(assist_text_first_click_coded, assist_text_last_click_coded) %>%
summary() %>%
kable("html", col.names=(c("Assist Text First Click in sec", "Assist Text Last Click in sec"))) %>%
kable_styling(bootstrap_options = c("striped", "hover"))
|
Assist Text First Click in sec
|
Assist Text Last Click in sec
|
|
Min. : 1.486
|
Min. : 8.704
|
|
1st Qu.: 8.472
|
1st Qu.:26.649
|
|
Median :22.005
|
Median :57.654
|
|
Mean :19.544
|
Mean :53.364
|
|
3rd Qu.:26.626
|
3rd Qu.:75.235
|
|
Max. :42.822
|
Max. :95.026
|
|
NA’s :61
|
NA’s :70
|
- Combine reasonable budget responses
data <- data %>%
mutate(reasonable_budget_coded = coalesce(reasonable_budget100_1, reasonable_budget200_1))
data %>% count(reasonable_budget_coded) %>%
kable("html", col.names=(c("Reasonable Budget", "N"))) %>%
kable_styling(bootstrap_options = c("striped", "hover"))
Reasonable Budget
|
N
|
10
|
1
|
20
|
3
|
30
|
1
|
50
|
6
|
90
|
1
|
100
|
2
|
210
|
1
|
220
|
1
|
250
|
1
|
300
|
2
|
NA
|
61
|
Merging payment status to main data
In data_payment
dataset, variable
payment_status
== SUCCESSFUL
if the payment
was successful. Merging this variable to the main dataset using
ResponseID
as the key.
data_payment <- data_payment %>%
select(ResponseId, payment_status)
data <- left_join(data, data_payment, by = "ResponseId")
data %>% count(payment_status) %>%
kable("html", col.names=(c("Payment Status", "N"))) %>%
kable_styling(bootstrap_options = c("striped", "hover"))
Payment Status
|
N
|
SUCCESSFUL
|
20
|
NA
|
60
|
data %>% group_by(arm_coded) %>% count(payment_status) %>%
kable("html", col.names=(c("Arm", "Payment Status", "N"))) %>%
kable_styling(bootstrap_options = c("striped", "hover"))
Arm
|
Payment Status
|
N
|
|
SUCCESSFUL
|
1
|
|
NA
|
60
|
treatment_100
|
SUCCESSFUL
|
10
|
treatment_200
|
SUCCESSFUL
|
9
|