df_pings2_bp <-
dget ("pings_2_data_with_bps_ready" ) %>%
mutate (
female = a_gender == "Female" ,
nihss_levcon = str_extract (z_levcon, "^ \\ d+" ) %>%
as.numeric (),
nihss_loc_quest = str_extract (z_loc_quest, "^ \\ d+" ) %>%
as.numeric (),
nihss_loc_comm = str_extract (z_loc_comm, "^ \\ d+" ) %>%
as.numeric (),
nihss_bestgaze = str_extract (z_bestgaze, "^ \\ d+" ) %>%
as.numeric (),
nihss_vfield = str_extract (z_vfield, "^ \\ d+" ) %>%
as.numeric (),
nihss_facparesis = str_extract (z_facparesis, "^ \\ d+" ) %>%
as.numeric (),
nihss_motor_armr = str_extract (z_motor_armr, "^ \\ d+" ) %>%
as.numeric (),
nihss_motor_arml = str_extract (z_motor_arml, "^ \\ d+" ) %>%
as.numeric (),
nihss_motor_legr = str_extract (z_motor_legr, "^ \\ d+" ) %>%
as.numeric (),
nihss_motor_legl = str_extract (z_motor_legl, "^ \\ d+" ) %>%
as.numeric (),
nihss_limbataxia = str_extract (z_limbataxia, "^ \\ d+" ) %>%
as.numeric (),
nihss_pinprick = str_extract (z_pinprick, "^ \\ d+" ) %>%
as.numeric (),
nihss_bestlang = str_extract (z_bestlang, "^ \\ d+" ) %>%
as.numeric (),
nihss_dysarthria = str_extract (z_dysarthria, "^ \\ d+" ) %>%
as.numeric (),
nihss_extinction = str_extract (z_extinction, "^ \\ d+" ) %>%
as.numeric (),
nihss_scale = nihss_levcon + nihss_loc_quest + nihss_loc_comm +
nihss_bestgaze + nihss_vfield + nihss_facparesis +
nihss_motor_armr + nihss_motor_arml + nihss_motor_legr +
nihss_motor_legl + nihss_limbataxia + nihss_pinprick +
nihss_bestlang + nihss_dysarthria + nihss_extinction,
ranking = str_extract (x_ranking, " \\ d+" ) %>%
as.numeric (),
dm = case_when (
ff_hba1c_0 > 6.5 ~ "Yes" ,
c_dm == "Yes" ~ "Yes" ,
h_antidm == "Yes" ~ "Yes" ,
ff_fbs_0 > 7 ~ "Yes" ,
eventname == "Baseline" ~ "No" ),
hba1c_high = case_when (
ff_hba1c_0 < 6.5 ~ "No" ,
ff_hba1c_0 >= 6.5 ~ "Yes" ),
hpt = case_when (
sbp >= 140 ~ "Yes" ,
dbp >= 90 ~ "Yes" ,
sbp < 140 ~ "No" ,
dbp < 90 ~ "No" ) %>% factor (),
hyperlipidemia = case_when (
c_hyperlip == "Yes" ~ "Yes" ,
h_antilipid == "Yes" ~ "Yes" ,
ff_totchol_0 > 5.17 ~ "Yes" ,
eventname == "Baseline" ~ "No" ),
tobacco_use = case_when (g_tobacco %in% c (
"Formerly used tobacco products" ,
"Stopped after the stroke occurred" ,
"Currently uses tobacco products" ) ~ "Yes" ,
g_tobacco == "Never used tobacco products" ~ "No" ),
obese_overwgt = case_when (
ee_bmi_0 >= 25 ~ "Yes" ,
ee_bmi_0 < 25 ~ "No" ),
bmi_cat = case_when (
ee_bmi_0 < 25 ~ "Normal" ,
ee_bmi_0 < 30 ~ "Overweight" ,
ee_bmi_0 >= 30 ~ "Obese" ) %>%
factor (levels = c ("Normal" , "Overweight" , "Obese" )),
alcohol_curr = case_when (
g_alcohol == "Currently uses alcohol" ~ "Yes" ,
g_alcohol %in% c (
"Never used alcohol" ,
"Past 12 months" ,
"Past 30 days" ,
"Formerly used alcohol" ,
"Stopped after the stroke occured" ) ~ "No" ),
acei = i_acei_v2 == "Checked" ,
arb = i_arb_v2 == "Checked" ,
bb = i_bb_v2 == "Checked" ,
ccb = i_ccb_v2 == "Checked" ,
h_alpha_md = i_alpha_md_v2 == "Checked" ,
h_alpha_ab = i_alpha_ab_v2 == "Checked" ,
diuretics = i_diuretics_v2 == "Checked" ,
h_antiplt = i_antiplt_v2 == "Yes" ,
h_statins = i_statins_v2 == "Yes" ,
income2 = case_when (
a_income %in% c ("0-100" , "101-250" , "251-500" ) ~ "<500 GHc" ,
a_income %in% c ("501-1500" , "1501-3000" , "> 3000" ) ~
">= 500 GHc" ),
educ = fct_recode (a_formeduc, Tertiary = "Postgraduate" ),
educ2 = case_when (
a_formeduc %in% c ("None" , "Primary" ) ~ "None/Primary" ,
a_formeduc %in% c ("Secondary" , "Tertiary" , "Postgraduate" ) ~
"Secondary or higher" ),
agecat = case_when (
a_agebase < 60 ~ "<60" , a_agebase >= 60 ~ ">=60" ),
hosp_cat = case_when (
datagrp %in% c ("CCTH SITE" , "KATH SITE" , "KORLE-BU SITE" ) ~
"Tertiary" ,
datagrp %in% c (
"KUMASI SOUTH HOSPITAL" , "AGOGO SITE" , "KNUST SITE" ) ~
"Secondary" ,
datagrp %in% c (
"ANKAASE SITE" , "MANHYIA GOVT HOSPITAL" , "KWADASO SITE" ,
"TAFO SITE" ) ~
"Primary" ),
arm = case_when (
arm == "Arm 1- Intervention Arm" ~ "Intervention" ,
arm == "Arm 2- Routine Care" ~ "Routine" ),
morisky_4_item = (unclass (k_forget) + unclass (k_miss) +
unclass (k_fine) + unclass (k_doctor)),
across (
c (l_forget, l_decide, l_salty, l_shake, l_fasfood, l_appoint,
l_missched, l_prescrip, l_runout, l_skipmed, l_feelbet,
l_feelsick, l_someone, l_careless),
.fns = ~ factor (.x),
.names = "{.col}_unclassed" ),
across (
c (l_forget_unclassed, l_decide_unclassed, l_salty_unclassed,
l_shake_unclassed, l_fasfood_unclassed, l_appoint_unclassed,
l_missched_unclassed, l_prescrip_unclassed, l_runout_unclassed,
l_skipmed_unclassed, l_feelbet_unclassed, l_feelsick_unclassed,
l_someone_unclassed, l_careless_unclassed),
.fns = ~ unclass (.x)),
hillbone = (
l_forget_unclassed + l_decide_unclassed + l_salty_unclassed +
l_shake_unclassed + l_fasfood_unclassed + l_appoint_unclassed +
l_missched_unclassed + l_prescrip_unclassed +
l_runout_unclassed + l_skipmed_unclassed + l_feelbet_unclassed +
l_feelsick_unclassed + l_someone_unclassed +
l_careless_unclassed) %>%
as.numeric (),
aa_bp_115_75_corrrect = ifelse (
aa_bp_115_75 == "Normal" , "Yes" , "No" ),
aa_bp160_100_correct = ifelse (
aa_bp160_100 == "High" , "Yes" , "No" ),
aa_hptlasts_correct = ifelse (
aa_hptlasts == "The Rest of their Life" , "Yes" , "No" ),
aa_hptmeds_correct = ifelse (aa_hptmeds == "Everyday" , "Yes" , "No" ),
aa_losewght_correct = ifelse (aa_losewght == "Go Down" , "Yes" , "No" ),
aa_eatsalt_correct = ifelse (aa_eatsalt == "Go Down" , "Yes" , "No" ),
aa_hrtattack_correct = ifelse (aa_hrtattack == "Yes" , "Yes" , "No" ),
aa_cancer_correct = ifelse (aa_cancer == "No" , "Yes" , "No" ),
aa_stroke_correct = ifelse (aa_stroke == "Yes" , "Yes" , "No" ),
aa_kidneyp_correct = ifelse (aa_kidneyp == "Yes" , "Yes" , "No" ),
aa_highrisk_correct = ifelse (aa_highrisk == "Yes" , "Yes" , "No" ),
aa_headache_correct = ifelse (aa_headache == "No" , "Yes" , "No" ),
aa_feelgood_correct = ifelse (aa_feelgood == "Never" , "Yes" , "No" ),
aa_strokeris_correct = ifelse (
aa_strokeris == "The Rest of Their Life" , "Yes" , "No" ),
aa_hkq = (aa_bp_115_75_corrrect == "Yes" ) +
(aa_bp160_100_correct == "Yes" ) +
(aa_hptlasts_correct == "Yes" ) +
(aa_hptmeds_correct == "Yes" ) +
(aa_losewght_correct == "Yes" ) +
(aa_eatsalt_correct == "Yes" ) +
(aa_hrtattack_correct == "Yes" ) +
(aa_cancer_correct == "Yes" ) +
(aa_stroke_correct == "Yes" ) +
(aa_kidneyp_correct == "Yes" ) +
(aa_highrisk_correct == "Yes" ) +
(aa_headache_correct == "Yes" ) +
(aa_feelgood_correct == "Yes" ) +
(aa_strokeris_correct == "Yes" ),
mobility = case_when (
str_detect (
p_mobility , "I have no problems in walking about" ) ~ "1" ,
str_detect (
p_mobility , "I have some problems in walking about" ) ~ "2" ,
str_detect (
p_mobility , "I am confined to bed" ) ~ "3" )%>%
as.numeric (),
selfcare = case_when (
str_detect (
p_selfcare , "I have no problems with self-care" ) ~ "1" ,
str_detect (
p_selfcare , "I have some problems with washing or" ) ~ "2" ,
str_detect (
p_selfcare ,
"I am unable to wash or dress myself" ) ~ "3" )%>%
as.numeric (),
usual_act = case_when (
str_detect (
p_usual_act ,
"I have no problems with performing my" ) ~ "1" ,
str_detect (
p_usual_act , "I have some problems with performing" ) ~ "2" ,
str_detect (
p_usual_act , "I am unable to perform my usual activitie" ) ~
"3" )%>%
as.numeric (),
pain_disc = case_when (
str_detect (p_pain_disc , "I have no pain or discomfort" ) ~ "1" ,
str_detect (
p_pain_disc , "I have moderate pain or discomfort" ) ~ "2" ,
str_detect (
p_pain_disc ,
"I have extreme pain or discomfort" ) ~ "3" ) %>%
as.numeric (),
anxiety = case_when (
str_detect (p_anxiety, "I am not anxious or depressed" ) ~ "1" ,
str_detect (
p_anxiety, "I am moderately anxious or depressed" ) ~ "2" ,
str_detect (
p_anxiety, "I am extremely anxious or depressed" ) ~ "3" )%>%
as.numeric (),
eq_5d = mobility + selfcare + usual_act + pain_disc + anxiety,
p_health = ifelse (p_health <= 1 , p_health* 100 , p_health),
across (
c (bb_physical, bb_nutfacts, bb_repsalt, bb_limsalt, bb_tabsalt,
bb_eatsfood,
bb_broilst, bb_rsfoods, bb_rephfat, bb_totcal, bb_eatveges,
bb_alcohol, bb_smoking, bb_bpathome, bb_fbpmeds, bb_takemeds,
bb_wgtdown, bb_monitst, bb_streslow, bb_doctor, bb_physical2,
bb_nutfacts2, bb_repsalt2,bb_limsalt2, bb_tabsalt2,
bb_eatsfood2, bb_broilst2, bb_rsfoods2, bb_rephfat2,
bb_totcal2, bb_eatveges2, bb_alcohol2, bb_smoking2,
bb_bpathome2, bb_fbpmeds2, bb_takemeds2, bb_wgtdown2,
bb_monitst2, bb_streslow2, bb_doctor2, bb_physical3,
bb_nutfacts3, bb_repsalt3, bb_limsalt3, bb_tabsalt3,
bb_eatsfood3, bb_broilst3, bb_rsfoods3, bb_rephfat3,
bb_totcal3, bb_eatveges3, bb_alcohol3, bb_smoking3,
bb_bpathome3, bb_fbpmeds3, bb_takemeds3, bb_wgtdown3,
bb_monitst3, bb_streslow3, bb_doctor3),
.fns = ~ factor (.x),
.names = "{.col}_unclassed" ),
across (
c (bb_physical_unclassed, bb_nutfacts_unclassed,
bb_repsalt_unclassed,
bb_limsalt_unclassed, bb_tabsalt_unclassed,
bb_eatsfood_unclassed,
bb_broilst_unclassed, bb_rsfoods_unclassed,
bb_rephfat_unclassed,
bb_totcal_unclassed, bb_eatveges_unclassed,
bb_alcohol_unclassed,
bb_smoking_unclassed, bb_bpathome_unclassed,
bb_fbpmeds_unclassed,
bb_takemeds_unclassed, bb_wgtdown_unclassed,
bb_monitst_unclassed,
bb_streslow_unclassed, bb_doctor_unclassed,
bb_physical2_unclassed,
bb_nutfacts2_unclassed, bb_repsalt2_unclassed,
bb_limsalt2_unclassed,
bb_tabsalt2_unclassed, bb_eatsfood2_unclassed,
bb_broilst2_unclassed,
bb_rsfoods2_unclassed, bb_rephfat2_unclassed,
bb_totcal2_unclassed,
bb_eatveges2_unclassed, bb_alcohol2_unclassed,
bb_smoking2_unclassed,
bb_bpathome2_unclassed, bb_fbpmeds2_unclassed,
bb_takemeds2_unclassed,
bb_wgtdown2_unclassed, bb_monitst2_unclassed,
bb_streslow2_unclassed,
bb_doctor2_unclassed, bb_physical3_unclassed,
bb_nutfacts3_unclassed,
bb_repsalt3_unclassed, bb_limsalt3_unclassed,
bb_tabsalt3_unclassed,
bb_eatsfood3_unclassed, bb_broilst3_unclassed,
bb_rsfoods3_unclassed,
bb_rephfat3_unclassed, bb_totcal3_unclassed,
bb_eatveges3_unclassed,
bb_alcohol3_unclassed, bb_smoking3_unclassed,
bb_bpathome3_unclassed,
bb_fbpmeds3_unclassed, bb_takemeds3_unclassed,
bb_wgtdown3_unclassed,
bb_monitst3_unclassed, bb_streslow3_unclassed,
bb_doctor3_unclassed),
.fns = ~ unclass (.x)),
across (
c (bb_fbpmeds_unclassed, bb_takemeds_unclassed,
bb_fbpmeds2_unclassed, bb_takemeds2_unclassed,
bb_fbpmeds3_unclassed, bb_takemeds3_unclassed),
.fns = ~ 0 - .x + 5 ),
hpt_self_care = bb_physical_unclassed + bb_nutfacts_unclassed +
bb_repsalt_unclassed +
bb_limsalt_unclassed + bb_tabsalt_unclassed +
bb_eatsfood_unclassed +
bb_broilst_unclassed + bb_rsfoods_unclassed +
bb_rephfat_unclassed +
bb_totcal_unclassed + bb_eatveges_unclassed +
bb_alcohol_unclassed +
bb_smoking_unclassed + bb_bpathome_unclassed +
bb_fbpmeds_unclassed +
bb_takemeds_unclassed + bb_wgtdown_unclassed +
bb_monitst_unclassed +
bb_streslow_unclassed + bb_doctor_unclassed +
bb_physical2_unclassed +
bb_nutfacts2_unclassed + bb_repsalt2_unclassed +
bb_limsalt2_unclassed +
bb_tabsalt2_unclassed + bb_eatsfood2_unclassed +
bb_broilst2_unclassed +
bb_rsfoods2_unclassed + bb_rephfat2_unclassed +
bb_totcal2_unclassed +
bb_eatveges2_unclassed + bb_alcohol2_unclassed +
bb_smoking2_unclassed +
bb_bpathome2_unclassed + bb_fbpmeds2_unclassed +
bb_takemeds2_unclassed +
bb_wgtdown2_unclassed + bb_monitst2_unclassed +
bb_streslow2_unclassed +
bb_doctor2_unclassed + bb_physical3_unclassed +
bb_nutfacts3_unclassed +
bb_repsalt3_unclassed + bb_limsalt3_unclassed +
bb_tabsalt3_unclassed +
bb_eatsfood3_unclassed + bb_broilst3_unclassed +
bb_rsfoods3_unclassed +
bb_rephfat3_unclassed + bb_totcal3_unclassed +
bb_eatveges3_unclassed +
bb_alcohol3_unclassed + bb_smoking3_unclassed +
bb_bpathome3_unclassed +
bb_fbpmeds3_unclassed + bb_takemeds3_unclassed +
bb_wgtdown3_unclassed +
bb_monitst3_unclassed + bb_streslow3_unclassed +
bb_doctor3_unclassed,
sbp_2 = sbp,
dbp_2 = dbp,
sbp_baseline = case_when (eventname == "Baseline" ~ sbp),
dbp_baseline = case_when (eventname == "Baseline" ~ dbp),
stroke_type = case_when (
d_st_type == "Ischemic Stroke" ~ "Ischemic" ,
d_st_type ==
"Intracerebral Hemorrhagic Stroke" ~ "Hemorrhagic" ) %>%
factor (),
hosp_cat2 = case_when (
hosp_cat %in% c ("Primary" ,"Secondary" ) ~ "Primary/Secondary" ,
hosp_cat == "Tertiary" ~ "Tertiary" ),
egfr0 = parse_number (ff_egfr_0),
egfr0 = ifelse (egfr0 < 1 , egfr0* 100 , egfr0),
egfr_cat = case_when (egfr0 < 60 ~ "<60" , egfr0 >= 60 ~ ">=60" ),
across (
c (m12_pratio_1, m12_pratio_2, m12_pratio_3, m12_pratio_4,
m12_pratio_5, m12_pratio_6, m12_pratio_7, m12_pratio_8),
~ parse_number (.)),
emerg_visit = case_when (
gg_emerg_0 == "seizure" ~ "Yes" ,
gg_emerg_1 == "Stage III HPT" ~ "Yes" ,
gg_emerg_3 %in% c ("Seizure" ,"Yes" ) ~ "Yes" ,
gg_emerg_6 %in% c ("seizure (recurrent stroke)" , "YES" ) ~ "Yes" ,
eventname == "Baseline" ~ "No" ),
emerg_visit = emerg_visit == "Yes" ,
mpr12 = rowMeans (
across (
c (m12_pratio_1, m12_pratio_2, m12_pratio_3, m12_pratio_4,
m12_pratio_5, m12_pratio_6, m12_pratio_7, m12_pratio_8)),
na.rm= T),
mpr12 = ifelse (mpr12 < 10 , mpr12* 10 , mpr12),
mpr12 = ifelse (mpr12 > 200 , mpr12/ 10 , mpr12),
mpr12 = ifelse (mpr12 > 100 , 100 , mpr12),
sbp_gr_eq_160_baseline = case_when (
sbp < 160 & eventname == "Baseline" ~ "<160mmHg" ,
sbp >= 160 & eventname == "Baseline" ~ ">=160mmHg" )) %>%
arrange (pid, eventname) %>%
group_by (pid) %>%
fill (
sbp_2, dbp_2, arm, sbp_baseline, dbp_baseline, emerg_visit, dm,
d_st_type, arm) %>%
ungroup () %>%
mutate (
sbp_less_140_itt = sbp_2 < 140 ,
sbp_less_140_pp = sbp < 140 ,
bp_less_140_90_itt = (sbp_2 < 140 & dbp_2 < 90 ),
bp_less_140_90_pp = (sbp < 140 & dbp < 90 ),
sbp_diff = sbp_baseline - sbp,
dbp_diff = dbp_baseline - dbp,
sbp_diff_itt = sbp_baseline - sbp_2,
dbp_diff_itt = dbp_baseline - dbp_2,
sbp_less_135_itt = sbp_2 < 135 ,
sbp_less_135_pp = sbp < 135 ,
sbp_less_130_itt = sbp_2 < 130 ,
sbp_less_130_pp = sbp < 130 ,
review_no = case_when (
eventname == "Baseline" & ! is.na (sbp) ~ 0 ,
eventname == "Month 1" & ! is.na (sbp) ~ 1 ,
eventname == "Month 3" & ! is.na (sbp) ~ 3 ,
eventname == "Month 6" & ! is.na (sbp) ~ 6 ,
eventname == "Month 9" & ! is.na (sbp) ~ 9 ,
eventname == "Month12" & ! is.na (sbp) ~ 12 ),
d_st_type_2 = fct_recode (
d_st_type,
"Ischemic Stroke" =
"Ischemic With Hemorrhagic Transformation" )) %>%
arrange (pid, eventname) %>%
group_by (pid) %>%
mutate (
max_review = max (review_no, na.rm = T),
completed_study = case_when (
max_review == 12 ~ "Yes" , TRUE ~ "No" ) %>% factor ()) %>%
ungroup ()