df_pings2_bp <-
pings2_data %>%
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"),
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"),
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"),
alcohol_ever = case_when(
g_alcohol %in% c(
"Currently uses alcohol",
"Past 12 months",
"Past 30 days",
"Formerly used alcohol",
"Stopped after the stroke occured") ~ "Yes",
g_alcohol %in% c("Never used alcohol") ~ "No") %>%
factor(),
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"),
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") %>%
factor(levels = c("Tertiary", "Secondary", "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),
d_st_type =as.character(d_st_type),
stroke_type = case_when(
d_st_type == "Ischemic Stroke" ~ "Ischemic",
d_st_type == "Intracerebral Hemorrhagic Stroke" ~ "Hemorrhagic",
d_st_type == "Ischemic With Hemorrhagic Transformation" ~ "Ischemic",
d_st_type == "Untyped Stroke (no CT scan available)" ~ "Untyped") %>% 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_base_cat = 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)) %>%
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() %>%
mutate(
p_mobility, p_selfcare, p_usual_act, p_pain_disc,
p_anxiety, p_health,
r_hamd_total,
s_g10worth, s_g11help, s_g12depress, s_g13hope, s_h2control,
s_h3ability, s_h4things, s_h5overcome,
x_ranking,
z_levcon, z_loc_quest, z_loc_comm, z_bestgaze, z_vfield,
z_facparesis, z_motor_armr, z_motor_arml, z_motor_legr,
z_motor_legl, z_limbataxia, z_pinprick, z_bestlang,
z_dysarthria, z_extinction,
aa_bp_115_75:aa_strokeris,
ee_bmi_0, ee_sbp_0, ee_dbp_0, ee_waistc_0, ee_whrat_1, ee_hipc_0,
ee_bmi_0, ee_waistc_0, ee_wgt_0, ee_heightcm, ee_sbp_12,
ff_hba1c_0, ff_creat_0, ff_totchol_0, ff_ldl_0, ff_hdl_0,
ff_trigly_0, ff_egfr_0, ff_fbs_0
) %>%
mutate(
a_livingsit2 = case_when(
a_livingsit == "Lives Alone" ~ "Lives without family",
a_livingsit == "Lives With Spouse and Children" ~ "Lives with family",
a_livingsit == "Lives in a Nursing Home" ~ "Lives without family",
a_livingsit == "Lives With Spouse" ~ "Lives with family",
a_livingsit == "Lives With Extended Family" ~ "Lives with family",
a_livingsit == "Lives With Children" ~ "Lives with family"),
educ = fct_recode(a_formeduc, Tertiary = "Postgraduate"),
income = fct_collapse(
a_income, ">500" = c("501-1500", "1501-3000", "> 3000")),
maristat = fct_recode(
a_maristat, "Previously Married" = "Separated",
"Previously Married" = "Widow/Widower",
"Previously Married" = "Divorced",
"Currently Married" = "Cohabitating") %>%
fct_relevel(
c("Currently Married", "Previously Married",
"Never Married")),
dm = case_when(
ff_hba1c_0 > 6.5 ~ "Yes", c_dm == "Yes" ~ "Yes",
h_antidm == "Yes" ~ "Yes", ff_fbs_0 > 7 ~ "Yes",
TRUE ~ "No"),
hyperlipidemia = case_when(
c_hyperlip == "Yes" ~ "Yes", h_antilipid == "Yes" ~ "Yes",
ff_totchol_0 > 5.17 ~ "Yes", TRUE ~ "No"),
#---
active_wh2 = as.character(g_active_wh),
active_wh2 = case_when(active_wh2 == "" ~ "0", TRUE ~ active_wh2),
active_wh2 = str_extract(active_wh2, "\\d+") %>% parse_number(),
active_wm2 = as.character(g_active_wm),
active_wm2 = case_when(active_wm2 == "" ~ "0", TRUE ~ active_wm2),
active_wm2 = str_extract(active_wm2, "\\d+") %>% parse_number(),
active_work_hrs = case_when(
(g_active_wh == "" & g_active_wm == "") ~ NA,
TRUE ~ active_wm2 + 60*active_wh2)/60,
#---
active_wh2 = as.character(g_active_lei),
active_wh2 = case_when(active_wh2 == "" ~ "0", TRUE ~ active_wh2),
active_wh2 = str_extract(active_wh2, "\\d+") %>% parse_number(),
active_wm2 = as.character(g_active_wm2),
active_wm2 = case_when(active_wm2 == "" ~ "0", TRUE ~ active_wm2),
active_wm2 = str_extract(active_wm2, "\\d+") %>% parse_number(),
active_leisure_hrs = case_when(
(g_active_lei == "" & g_active_wm2 == "") ~ NA,
TRUE ~ active_wm2 + 60*active_wh2)/60,
bmi = ee_wgt_0/(ee_heightcm/100)^2,
waist_hip_ratio = ee_waistc_0/ee_hipc_0,
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"),
egfr = str_extract(ff_egfr_0, "\\d+") %>% as.numeric(),
egfr_cat = case_when(
egfr < 60 ~ "<60",
egfr >= 60 & egfr <= 89~ "60 to 89",
egfr > 89 ~ ">89"
) %>% factor(levels = c("<60", "60 to 89", ">89")),
ranking = str_extract(x_ranking, "\\d+") %>% as.numeric(),
barthels_feed = ifelse(y_feeding == "O= unable", "0", as.character(y_feeding)) %>%
str_extract("^\\d+") %>%
as.numeric(),
barthels_bathing = str_extract(y_bathing, "^\\d+") %>% as.numeric(),
barthels_grooming = str_extract(y_grooming, "^\\d+") %>% as.numeric(),
barthels_dressing = str_extract(y_dressing, "^\\d+") %>% as.numeric(),
barthels_bowels = str_extract(y_bowels, "^\\d+") %>% as.numeric(),
barthels_bladder = str_extract(y_bladder, "^\\d+") %>% as.numeric(),
barthels_toilet = str_extract(y_toilet, "^\\d+") %>% as.numeric(),
barthels_bedtochair = str_extract(y_bedtochair, "^\\d+") %>% as.numeric(),
barthels_mobility = str_extract(y_mobility, "^\\d+") %>% as.numeric(),
barthels_stairs = str_extract(y_stairs, "^\\d+") %>% as.numeric(),
barthels_index = barthels_bathing + barthels_grooming + barthels_dressing +
barthels_bowels + barthels_bladder + barthels_toilet +
barthels_bedtochair + barthels_mobility + barthels_stairs,
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,
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,
vas = p_health,
vas_cat = ifelse(vas < median(vas, na.rm=TRUE), "Below Median", "Median & above"),
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"),
aa_hkq_cat = ifelse(
aa_hkq <= median(aa_hkq, na.rm=T), "Median & below", "Above Median"
) %>% factor(levels = c("Median & below", "Above Median")),
male = case_when(a_gender == "Male" ~ "Yes", a_gender == "Female" ~ "No"),
active_leisure_hrs = ifelse(
active_leisure_hrs > 16,
median(active_leisure_hrs, na.rm=TRUE), active_leisure_hrs),
active_work_hrs = ifelse(
active_work_hrs > 16,
median(active_work_hrs, na.rm=TRUE), active_work_hrs),
bmi = ifelse(bmi >70, median(bmi, na.rm = TRUE), bmi),
ee_dbp_0 = ifelse(ee_dbp_0 <1, ee_dbp_0*100, ee_dbp_0),
ee_waistc_0 =ifelse(
ee_waistc_0 < 10, median(ee_waistc_0, na.rm=TRUE), ee_waistc_0),
ff_creat_0 = ifelse(ff_creat_0 < 5, ff_creat_0*10, ff_creat_0),
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"
),
across(
c(s_g10worth, s_g11help, s_g12depress, s_g13hope, s_h2control,
s_h3ability, s_h4things, s_h5overcome),
.fns = ~fct_na_level_to_value(.x, "Refused")),
across(
c(s_g10worth, s_g11help, s_g12depress, s_g13hope, s_h2control,
s_h3ability, s_h4things, s_h5overcome),
.fns = ~factor(.x),
.names = "{.col}_unclassed"),
across(
c(s_g10worth_unclassed, s_g11help_unclassed, s_g12depress_unclassed,
s_g13hope_unclassed, s_h2control_unclassed, s_h3ability_unclassed,
s_h4things_unclassed, s_h5overcome_unclassed),
.fns = ~unclass(.x)),
s_h3ability_unclassed = 6 - s_h3ability_unclassed,
s_h4things_unclassed = 6 - s_h4things_unclassed,
across(
c(s_g10worth_unclassed, s_g11help_unclassed, s_g12depress_unclassed,
s_g13hope_unclassed, s_h2control_unclassed, s_h3ability_unclassed,
s_h4things_unclassed, s_h5overcome_unclassed),
.fns = ~.x-3),
perceived_stress = s_g10worth_unclassed + s_g11help_unclassed +
s_g12depress_unclassed + s_g13hope_unclassed + s_h2control_unclassed +
s_h3ability_unclassed + s_h4things_unclassed + s_h5overcome_unclassed,
perceived_stress_cat = ifelse(
perceived_stress <= median(perceived_stress, na.rm=TRUE), "Low", "High") %>%
factor(levels = c("Low", "High")),
hamd_cat = case_when(
r_hamd_total <= 8 ~ "Normal",
r_hamd_total < 14 ~ "Mild Depression",
r_hamd_total < 19 ~ "Moderate Depression",
r_hamd_total < 23 ~ "Severe Depression",
r_hamd_total >= 23 ~ "Very Severe Depression"
) %>%
factor(
levels = c(
"Normal", "Mild Depression", "Moderate Depression",
"Severe Depression", "Very Severe Depression"),
ordered = TRUE),
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(),
hillbone_cat = ifelse(
hillbone >= median(hillbone, na.rm=TRUE), "High", "Low"),
hamd_cat_2 = fct_recode(
hamd_cat,
Moderate_Severe = "Moderate Depression",
Moderate_Severe = "Severe Depression",
Moderate_Severe = "Very Severe Depression"
) %>% factor(ordered = F),
a_poccup3 = a_poccup2 %>%
fct_recode(
Skilled = "Highly Skilled academic professional",
Skilled = "Skilled Worker",
Skilled = "Semi-Skilled Worker",
Manual = "Manual Worker",
Unemployed = "Home maker",
Unemployed = "Unemployed( Unable to work)",
Unemployed = "Unemployed ( able to work)",
Retired = "Retired",
Others = "Non-paid Worker",
Others = "Home maker"
) %>% fct_na_level_to_value("Student"),
morisky_4_score = (unclass(k_forget) + unclass(k_miss) +
unclass(k_fine) + unclass(k_doctor)),
morisky_4_raw = factor(morisky_4_score, ordered = TRUE),
morisky_4_cat = case_when(
morisky_4_score < 8 ~ "Low",
morisky_4_score == 8 ~ "High"
),
across(
c(o_headache, o_dizziness, o_thirst, o_edema, o_coldhands,
o_flush, o_fatigue, o_cough, o_palpitat, o_nausea,
o_constipat, o_drowsy, o_insomnia, o_dreams, o_frequent,
o_darker, o_depression, o_anxiety, o_libido, o_impotence),
.fns = ~(.x == "Checked"),
.names = "{.col}_new"),
side_effects = o_headache_new + o_dizziness_new + o_thirst_new +
o_edema_new + o_coldhands_new + o_flush_new + o_fatigue_new +
o_cough_new + o_palpitat_new + o_nausea_new +
o_constipat_new + o_drowsy_new + o_insomnia_new +
o_dreams_new + o_frequent_new + o_darker_new +
o_depression_new + o_anxiety_new + o_libido_new +
o_impotence_new,
mrs_cat = case_when(
ranking <= 2 ~ "0 to 2",
ranking > 2 ~ "3-6"),
barthel_cat = case_when(
barthels_index < 90 ~ "< 90",
barthels_index >= 90 ~ ">= 90"))