rm(list = ls(all = T))
library(tidyverse)
library(gtsummary)
gtsummary::theme_gtsummary_eda()
# Read in data
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()
df_pings2_bp <-
df_pings2_bp %>%
labelled::set_variable_labels(
female = "Gender, female",
d_st_type = "Type of Stroke",
nihss_scale ="Stroke Severity (NIHSS)",
ranking = "Modified Ranking Score",
dm = "Diabetes Mellitus",
sbp = "Systolic Blood Pressure",
dbp = "Diastolic Blood Pressure",
hpt = "Hypertesion",
hyperlipidemia = "Hyperlipidemia",
tobacco_use = "Cigarette smoking",
obese_overwgt = "Overweight & obesity",
alcohol_curr = "Alcohol use, current",
acei = "ACE-Inhibitors",
arb = "ARB",
bb = "B-blockers",
ccb = "Calcium channel blocker",
diuretics = "Diuretics",
female = "Gender, female",
income2 = "Income level",
educ2 = "Educational Level",
agecat = "Age in years",
h_alpha_md = "Alpha Methyl Dopa",
h_alpha_ab = "Alpha Adrenergic Blockers",
h_antiplt = "Antiplatelets",
h_statins = "Statins",
morisky_4_item = "Morisky (4 Items)",
hillbone = "Total Hillbone Score",
aa_hkq = "Health Literacy in HPT/stroke",
eq_5d = "Health Related QoL",
p_health = "Health Related QoL",
hpt_self_care = "Hypertension Self Care",
sbp_less_140_itt = "SBP < 140 mmHg at month 12 (ITT)",
sbp_less_140_pp = "SBP < 140 mmHg at month 12 (PP)",
bp_less_140_90_itt = "BP < 140/90 mmHg at month 12 (ITT)",
bp_less_140_90_pp = "BP < 140/90 mmHg at month 12 (PP)",
sbp_diff = "Change in SBP(month 12 from baseline - PP)",
dbp_diff = "Change in DBP(month 12 from baseline - PP)",
sbp_less_130_itt = "SBP < 130 mmHg at month 12 (ITT)",
sbp_less_130_pp = "SBP < 130 mmHg at month 12 (PP)",
sbp_less_135_itt = "SBP < 135 mmHg at month 12 (ITT)",
sbp_less_135_pp = "SBP < 135 mmHg at month 12 (PP)",
max_review = "Follow-up period",
review_no = "Review number",
completed_study = "Completed Study",
sbp_2 = "Systolic Blood Pressure (ITT)",
dbp_2 = "Systolic Blood Pressure (ITT)",
sbp_baseline = "Systolic Blood Pressure (Baseline)",
dbp_baseline = "Diastolic Blood Pressure (Baseline)",
sbp_diff_itt ="Change in SBP(month 12 from baseline)- ITT",
dbp_diff_itt = "Change in DBP(month 12 from baseline) - ITT")
df_drugs_class_raw <-
readxl::read_xlsx(
"drugs_data_clean_10122025.xlsx", sheet = 1) %>%
filter(!is.na(hpt_drug_class) & eventname == "Baseline")
df_drugs_class <-
readxl::read_xlsx(
"drugs_data_clean_10122025.xlsx", sheet = 1) %>%
filter(!is.na(hpt_drug_class) & eventname == "Baseline") %>%
select(pid, hpt_drug_class, antihpt) %>%
pivot_wider(
id_cols = pid,
names_from = hpt_drug_class,
values_from = antihpt) %>%
unnest(-pid) %>%
slice(-15) %>%
mutate(across(BB:`ALPHA BLOCKER`, ~ifelse(is.na(.x), 0, .x))) %>%
arrange(pid) %>%
distinct()
df_max_drug_doses_temp <-
readxl::read_xlsx(
"PINGS_Antihypertensive Maximum doses.xlsx", sheet = 2)
df_pings_cox <-
readxl::read_xlsx(
"PINGS_MACE and Participant follow-up review1.xlsx",
sheet = 2) %>%
janitor::clean_names() %>%
rename(
outc_all_cause = all_cause_death,
dura_outc = duration_of_follow_up,
mace = mace_1_0,
dura_mace = time_to_event) %>%
mutate(
participant_id_2 = sub("-(\\d)$", "-0\\1", participant_id_2),
pid = participant_id_2,
mace = case_when(is.na(mace) ~ 0, TRUE ~ mace),
dura_outc = case_when(
dura_outc > 380 ~ 380, TRUE ~ dura_outc),
dura_mace = case_when(
is.na(dura_mace) ~ dura_outc,
dura_mace > dura_outc ~ dura_outc,
TRUE ~ dura_mace),
dura_mace = case_when(dura_mace > 380 ~ 380, TRUE ~ dura_mace),
allocation_4 = factor(
allocation_4,
levels = c("Arm 2- Routine Care", "Arm 1- Intervention Arm"),
labels = c("Routine", "Intervention")),
mace_2 = factor(
mace,
levels = c(0, 1),
label = c("No", "Yes"))) %>%
select(
-c(serial_number, study_site_3,
vital_status_alive_0_dead_1_lost_2,
enrollment_date_5,
date_of_last_study_visit,
participant_id_9, study_site_10,
allocation_11,event_date,
enrollment_date_13, x19))
df_drugs <-
df_drugs_class_raw %>%
left_join(df_max_drug_doses_temp, by = "drug") %>%
mutate(
dose_index = freq_number*dose_number/maxi,
antihpt = case_when(is.na(antihpt) ~ 0, TRUE ~ antihpt)) %>%
filter(antihpt == 1) %>%
group_by(pid, eventname, arm) %>%
summarize(
n_hpts = sum(antihpt),
dose_index = sum(dose_index)) %>%
ungroup() %>%
filter(eventname == "Baseline")
df_for_mace_paper <-
df_pings2_bp %>% # labelled::look_for("statin")
filter(eventname %in% c("Baseline","Month12")) %>%
group_by(pid) %>%
mutate(completed_study = any(!is.na(sbp) & eventname == "Month12")) %>%
ungroup() %>%
filter(eventname == "Baseline") %>%
full_join(df_pings_cox) %>%
full_join(df_drugs_class) %>%
full_join(df_drugs) %>%
filter(!(!completed_study & mace_2 == "No")) %>%
mutate(across(BB:`ALPHA BLOCKER`, ~ifelse(is.na(.x), 0, .x))) %>%
select(
mace, mace_2, a_agebase, a_gender, educ, a_maristat, a_domicile,
a_income, a_religion, d_st_type, d_st_type_2, nihss_scale, ranking,
hyperlipidemia, hpt, sbp_gr_eq_160_baseline, dm, tobacco_use,
obese_overwgt, bmi_cat, ff_hba1c_0, hba1c_high, sbp, dbp,
BB:`ALPHA BLOCKER`, dose_index, h_antiplt, h_statins,
hillbone, aa_hkq, arm, dura_mace, hosp_cat)