library(tidyverse)
df_cathlab <-
readxl::read_xlsx(path = "CATHLAB REGISTRY DATA_Clean 4.xlsx") %>%
janitor::clean_names() %>%
rename(
baseline_hb = baseline_haematology_hb_13g_dl_male_11g_dl_female,
ldl_3months = monitoring_lipid_profile_ldl_c_at_3_months,
ldl_6months = monitoring_lipid_profile_ldl_c_at_6_months,
ldl_1year = monitoring_lipid_profile_ldl_c_at_1yr,
creatinine_48hrs = monitoring_creatinine_48hrs_post_procedure,
baseline_hba1c = baseline_haematology_hba1c_5_6_percent_non_diabetic_7_percent_diabetic,
nitroglycerin2 = nitroglycerin_premedication_dose_in_second_procedure_if_staged,
heparin_premed_2 = heparin_premedication_dose_in_second_procedure_if_staged,
coronary_angio = description_of_coronary_angiography_findings,
contrast_vol_2 = contrast_volume_in_second_procedure_if_staged,
creatinine_3months = monitoring_creatinine_3_months_post_procedure,
creatinine_1week = monitoring_creatinine_1_week_post_procedure,
film_no2 = film_number_of_second_procedure_if_staged,
baseline_plt = baseline_haematology_platelet_150_10_3_u_l,
second_access = reason_for_secondary_access_if_applicable,
sex = sex_1 ) %>%
mutate(
id = row_number(),
sex = factor(sex),
marital_status = case_when(
str_detect(marital_status, "arried") ~ "Married",
TRUE ~ marital_status),
nationality = case_when(
nationality == "Ghanaian, Non-Ghanaian" ~ "Ghanaian",
TRUE ~ nationality),
ethnicity = case_when(
ethnicity == "Akan, Ewe" ~ "Akan",
TRUE ~ ethnicity
) %>% fct_lump_prop(prop = .1, other_level = "Others"),
religion = case_when(
religion == "Christian, Bhuddist" ~ "Christian",
TRUE ~ religion),
occupation = case_when(
str_detect(occupation, "Private Sector") ~ "Private Sector",
str_detect(occupation, "Public Sector") ~ "Public Sector",
TRUE ~ occupation),
prev_cad = case_when(
prev_cad == "no" ~ "No", TRUE ~ prev_cad),
across(marital_status:phy_inactivity, ~factor(.)),
risk_factors = (hpn == "Yes") + (t2dm == "Yes") + (smoking == "Yes") +
(dyslip == "Yes") + (old_age == "Yes") + (obesity == "Yes") +
(alcohol == "Yes") + (f_hx_cad == "Yes") + (phy_inactivity == "Yes"),
risk_factors_cat = case_when(
risk_factors == 0 ~ "None",
(risk_factors > 0 & risk_factors < 4) ~ "1 to 3",
risk_factors >= 4 ~ "4 to 7") %>%
factor(levels = c("None", "1 to 3", "4 to 7")),
agecat = case_when(
age < 45 ~ "<45 years",
age >= 45 & age <= 65 ~ "45 to 65 years",
age > 66 ~ ">65 years") %>%
factor(levels=c("<45 years","45 to 65 years", ">65 years")),
type_of_lesion = factor(
type_of_lesion,
levels = c("Normal" ,"MNOD", "1VD", "2VD", "3VD", "LMD")),
race = fct_lump_prop(race, prop = 0.01, other_level = "Others"),
across(
c(lad_dx, rca_dx, lcx_dx),
~factor(.x, levels = c("Normal", "Mild", "Moderate", "Severe"))),
lad_dx_2 = case_when(
lad_dx == "Normal" ~ "No",
lad_dx %in% c("Mild", "Moderate", "Severe") ~ "Yes"),
rca_dx_2 = case_when(
rca_dx == "Normal" ~ "No",
rca_dx %in% c("Mild", "Moderate", "Severe") ~ "Yes"),
lcx_dx_2 = case_when(
lcx_dx == "Normal" ~ "No",
lcx_dx %in% c("Mild", "Moderate", "Severe") ~ "Yes"),
lm_severe_dxs = ifelse(lm_dx == "Severe", 1, 0),
rca_severe_dxs = ifelse(rca_dx == "Severe", 1, 0),
lcx_severe_dxs = ifelse(lcx_dx == "Severe", 1, 0),
lad_severe_dxs = ifelse(lad_dx == "Severe", 1, 0),
n_severe_dxs = (lm_dx == "Severe") + (rca_dx == "Severe") +
(lcx_dx == "Severe") + (lad_dx == "Severe"),
severe_dxs = case_when(
(lm_dx == "Severe" | rca_dx == "Severe" |
lcx_dx == "Severe" | lad_dx == "Severe") ~ "Yes",
n_severe_dxs == 0 ~ "No")) %>%
filter(procedure != "RHC") %>%
rename(ageyrs = age)