Mortality Manuscript

Author

Dr Samuel Blay Nguah

Importing and cleaning data

Code
df_anemia_ready <- 
    df_anemia %>% 
    janitor::clean_names() %>% 
    rename(
        history = does_the_child_have_a_history_of_the_following_check_all_that_applies,
        history_other = other_medical_history_specify, 
        eat_iron_veges = 
            does_the_child_eat_adequate_iron_rich_foods_regularly_e_g_meat_beans_leafy_vegetables, 
        exbf_4mths_older_chn = was_exclusive_breastfeeding_done_for_at_least_4_months_in_older_children, 
        bld_loss_3mths = recent_blood_loss_past_3_months_before_admission, 
        transfusion_3mths = recent_blood_transfusion_past_3_months_before_admission, 
        deworm_6mths = deworming_within_the_past_6_months_non_applicable_for_children_under_1_year, 
        iron_supp_3mths = iron_supplementation_within_the_past_3_months, 
        adm_clinical_features =clinical_features_at_admission_select_all_that_apply, 
        blood_film_comment = blood_film_comment_check_all_that_applies, 
        anemia_type = type_of_anemia_diagnosed_if_applicable, 
        txn_required = was_blood_transfusion_required,
        picu_required = was_patient_admitted_to_picu, 
        dura_hosp_stay = duration_of_hospital_stay_days, 
        missed_vac_opportunity = in_children_with_missed_immunizations_did_the_child_miss_opportunities_for_immunization_during_previous_admissions_or_opd_consultations, 
        missed_vac_reason = if_missed_vaccination_give_reason_for_incomplete_vaccination_status, 
        missed_vac_opportunity2 = for_children_who_have_missed_some_vaccinations_did_the_child_also_miss_opportunities_for_immunization_during_previous_admissions, 
        hb = hb_g_dl, 
        mal_prev = malaria_prevention_measures) %>% 
    mutate(
        age_days = interval(
            date_of_birth, date_of_admission) %/% days(1),
        age_months = interval(
            date_of_birth, date_of_admission) %/% months(1),
        age_years = interval(
            date_of_birth, date_of_admission) %/% years(1),
        adm_clinical_features = toupper(adm_clinical_features),
        across(
            c(gender, maternal_education, paternal_education, residence, 
              iron_supp_3mths, exbf_4mths_older_chn, transfusion_3mths, 
              picu_required, txn_required, rdt),
            ~factor(.)), 
        family_income = factor(
            family_income, 
            levels = c("Low", "Middle", "High")), 
        eat_iron_veges = factor(
            eat_iron_veges, 
            levels = c("No", "Yes")), 
        bld_loss_3mths_2 = case_when(
            bld_loss_3mths == "None" ~ "No", 
            TRUE ~ "Yes") %>% factor(), 
        mal_prev_use = case_when(
            mal_prev == "None" ~ "No", 
            TRUE ~ "Yes") %>% factor(),
        mal_prev = toupper(
            mal_prev),
        mal_prev_itn = case_when(
            str_detect(mal_prev, "ITN") ~ "Yes", 
            TRUE ~ "No" ) %>% factor(),
        mal_prev_spray_coil = case_when(
            str_detect(mal_prev, "COIL") ~ "Yes", 
            TRUE ~ "No" ) %>% factor(),
        mal_prev_clothes = case_when(
            str_detect(mal_prev, "CLOTH") ~ "Yes", 
            TRUE ~ "No" ) %>% factor(), 
        mal_prev_repellent = case_when(
            str_detect(mal_prev, "REPELLANT") ~ "Yes", 
            TRUE ~ "No") %>% factor(),
        mps_positive = case_when(
            malaria_parasites == "Positive" ~ "Yes", 
            malaria_parasites == "Negative" ~ "No") %>% 
            factor(), 
        rdt_positive = case_when(
            rdt == "Positive" ~ "Yes", 
            rdt == "Negative" ~ "No") %>% 
            factor(),
        deworm_6mths_2 = factor(
            deworm_6mths, levels = c("No", "Yes")),
        immun_status = case_when(
            immunization_status == "Fully vaccinated for age" ~ "Full",
            immunization_status == "Partially vaccinated for age" ~ 
                "Partial",
            immunization_status == "Not vaccinated" ~ "None") %>% 
            factor(levels = c("Full", "Partial", "None")),
        rbc_transfused = case_when(
            txn_required == "Yes" ~ "Yes", TRUE ~ "No") %>% factor(),
        died = case_when(
            outcome_at_discharge == "Died" ~ "Yes", 
            TRUE ~ "No") %>% factor(),
        anemia_cat = case_when(
            (age_years >= 15 & gender == "Male" & hb < 8) ~ "Severe",
            (age_years >= 15 & gender == "Male" & hb < 11) ~ "Moderate", 
            (age_years >= 15 & gender == "Male" & hb < 13) ~ "Mild", 
            (age_years >= 15 & gender == "Male") ~ "None", 
            (age_years >= 15 & gender == "Female" & hb < 8) ~ "Severe",
            (age_years >= 15 & gender == "Female" & hb < 11) ~ "Moderate", 
            (age_years >= 15 & gender == "Female" & hb < 12) ~ "Mild", 
            (age_years >= 15 & gender == "Female") ~ "None", 
            (age_years >= 12 & hb < 8) ~ "Severe",
            (age_years >= 12 & hb < 11) ~ "Moderate", 
            (age_years >= 12 & hb < 12) ~ "Mild", 
            (age_years >= 12) ~ "None", 
            (age_years >= 5 & hb < 8) ~ "Severe",
            (age_years >= 5 & hb < 11) ~ "Moderate", 
            (age_years >= 5 & hb < 11.5) ~ "Mild", 
            (age_years >= 5) ~ "None", 
            (age_months >= 24 & hb < 7) ~ "Severe",
            (age_months >= 24 & hb < 10) ~ "Moderate", 
            (age_months >= 24 & hb < 11) ~ "Mild", 
            (age_months >= 24) ~ "None", 
            (age_months >= 6 & hb < 7) ~ "Severe",
            (age_months >= 6 & hb < 9.5) ~ "Moderate", 
            (age_months >= 6 & hb < 10.5) ~ "Mild", 
            (age_months >= 6) ~ "None", 
            (age_months >= 1 & hb < 7) ~ "Severe",
            (age_months >= 1 & hb < 8) ~ "Moderate", 
            (age_months >= 1 & hb < 9) ~ "Mild", 
            (age_months >= 1) ~ "None") %>% 
            factor(levels = c("None", "Mild", "Moderate", "Severe")), 
        anemia = case_when(
            anemia_cat == "None" ~ "No", 
            anemia_cat %in% c("Mild", "Moderate", "Severe") ~ "Yes") %>% 
            factor(),
        mcv_cat = case_when(
            age_years > 12 & mcv > 96 ~ "Macrocytic", 
            age_years > 12 & mcv >= 80  ~ "Normocytic",
            age_years > 12 & mcv < 80  ~ "Microcytic",
            age_years > 6 & mcv > 90 ~ "Macrocytic", 
            age_years > 6 & mcv >= 78  ~ "Normocytic",
            age_years > 6 & mcv < 78  ~ "Microcytic",
            age_years >= 2 & mcv > 86 ~ "Macrocytic", 
            age_years >= 2 & mcv >= 75  ~ "Normocytic",
            age_years >= 2 & mcv < 75  ~ "Microcytic", 
            age_months >= 5 & mcv > 85 ~ "Macrocytic", 
            age_months >= 6 & mcv >= 73  ~ "Normocytic",
            age_months >= 6 & mcv < 73  ~ "Microcytic",
            age_months >= 1 & mcv > 108 ~ "Macrocytic", 
            age_months >= 1 & mcv >= 74  ~ "Normocytic",
            age_months >= 1 & mcv < 74  ~ "Microcytic") %>% 
            factor(levels = c("Microcytic", "Normocytic", "Macrocytic")),
        rdw_cat = case_when(
            (gender == "Male" & age_years > 12 & rdw_cv > 13.5) ~ "High", 
            (gender == "Male" & age_years > 12 & rdw_cv >= 10.9) ~ "Normal",
            (gender == "Male" & age_years > 12 & rdw_cv < 10.9)  ~ "Low",
            (gender == "Female" & age_years > 12 & rdw_cv > 14.6) ~ "High", 
            (gender == "Female" & age_years > 12 & rdw_cv >= 11.9)  ~ 
                "Normal",
            (gender == "Female" & age_years > 12 & rdw_cv < 11.9)  ~ "Low",
            age_years > 6 & rdw_cv > 13.8 ~ "High", 
            age_years > 6 & rdw_cv >= 11.9  ~ "Normal",
            age_years > 6 & rdw_cv < 11.9  ~ "Low",
            age_years >= 2 & rdw_cv > 14.6 ~ "High", 
            age_years >= 2 & rdw_cv >= 12.0  ~ "Normal",
            age_years >= 2 & rdw_cv < 12.0  ~ "Low",
            age_months >= 6 & rdw_cv > 15.6 ~ "High", 
            age_months >= 6 & rdw_cv >= 12.3  ~ "Normal",
            age_months >= 6 & rdw_cv < 12.3  ~ "Low",
            age_months >= 1 & rdw_cv > 16.5 ~ "High", 
            age_months >= 1 & rdw_cv >= 11.0  ~ "Normal",
            age_months >= 1 & rdw_cv < 11.0  ~ "Low") %>% 
            factor(levels = c("Low", "Normal", "High")) %>% 
            fct_recode("Normal" = "Low"),
        bld_film_done = case_when(
            is.na(blood_film_comment) ~ "No", 
            TRUE ~ "Yes") %>% factor(),
        bf_ida = case_when(
            str_detect(
                blood_film_comment, "Iron deficiency anemia") ~ "Yes",
            TRUE ~ "No") %>% factor(), 
        bf_scd = case_when(
            str_detect(
                blood_film_comment, "Sickle") ~ "Yes", 
            str_detect(blood_film_comment, "SCD") ~ "Yes",
            TRUE ~ "No") %>% factor(),
        bf_infection = case_when(
            str_detect(
                blood_film_comment, "Infection") ~ "Yes",
            TRUE ~ "No") %>% factor(),
        bf_liver = case_when(
            str_detect(
                blood_film_comment, "Liver") ~ "Yes",
            TRUE ~ "No") %>% factor(),
        bf_renal = case_when(
            str_detect(
                blood_film_comment, "Renal") ~ "Yes",
            TRUE ~ "No") %>% factor(), 
        bf_malignancy = case_when(
            str_detect(
                blood_film_comment, "ALL") ~ "Yes",
            str_detect(
                blood_film_comment, "MALIGNANCY") ~ "Yes",
            TRUE ~ "No") %>% factor(),
        bf_hemolytic = case_when(
            str_detect(
                blood_film_comment, "Hemolytic") ~ "Yes",
            TRUE ~ "No") %>% factor(),
        bf_malaria = case_when(
            str_detect(
                blood_film_comment, "Malaria") ~ "Yes",
            TRUE ~ "No") %>% factor(),
        bf_inflamation = case_when(
            str_detect(
                blood_film_comment, "INFLA") ~ "Yes",
            TRUE ~ "No") %>% factor(), 
        ida = case_when(
            bf_ida == "Yes" ~ "Yes",
            (hb < 10 & rdw_cv > 15 & mcv_cat == "Microcytic") ~ "Yes",
            TRUE ~ "No"),
        malaria = case_when(
            rdt_positive == "Yes" ~ "Yes", 
            mps_positive == "Yes" ~ "Yes",
            bf_malaria == "Yes" ~ "Yes",
            TRUE ~ "No"), 
        history = toupper(history),
        blood_film_comment = toupper(blood_film_comment),
        discharge_diagnosis_list = toupper(discharge_diagnosis_list),
        discharge_diagnosis_upper = toupper(discharge_diagnosis_upper),
        malnutrition = case_when(
            str_detect(history, "MALNUTRITION") ~ "Yes", 
            str_detect(history_other, "MALNUTRITION") ~ "Yes", 
            str_detect(discharge_diagnosis_upper, "MALNUTRITION") ~ "Yes", 
            TRUE ~ "No"),
        scd = case_when(
            str_detect(history, "SICKLE CELL DISEASE") ~ "Yes", 
            str_detect(history, "SCD") ~ "Yes", 
            str_detect(history_other, "SICKLE CELL DISEASE") ~ "Yes", 
            str_detect(history_other, "SCD") ~ "Yes", 
            str_detect(blood_film_comment, "SICKLE CELL DISEASE") ~ "Yes", 
            str_detect(blood_film_comment, "SCD") ~ "Yes", 
            str_detect(discharge_diagnosis_list, 
                       "SICKLE CELL DISEASE") ~ "Yes", 
            str_detect(discharge_diagnosis_list, "SCD") ~ "Yes", 
            str_detect(discharge_diagnosis_upper, 
                       "SICKLE CELL DISEASE") ~ "Yes", 
            str_detect(discharge_diagnosis_upper, "SCD") ~ "Yes",
            str_detect(anemia_type, "Sickle cell anemia") ~ "Yes",
            TRUE ~ "No"),
        g6pd = case_when(
            str_detect(discharge_diagnosis_list, "G6PD") ~ "Yes", 
            str_detect(discharge_diagnosis_upper, "G6PD") ~ "Yes", 
            str_detect(other_laboratory_findings, "G6PD") ~ "Yes", 
            str_detect(additional_comments, "G6PD") ~ "Yes", 
            TRUE ~ "No"), 
        anemia_of_malig = case_when(
        str_detect(blood_film_comment, "MALIGN") ~ "Yes", 
            TRUE ~ "No"),
        anemia_of_chr_dx = case_when(
            str_detect(blood_film_comment, "CHRONIC") ~ "Yes", 
            TRUE ~ "No"))%>%
    select(!c(column_42, column_43, timestamp))  %>% 
    full_join(df_anemia_diag) %>% 
    mutate(
        across(starts_with("diag_"), ~ifelse(is.na(.x), "No", .x)), 
        age_cat = case_when(
            (age_months >= 1 & age_months <= 5) ~ "3 to 5 months", 
            (age_months >= 6 & age_months <= 23) ~ "6 to 23 months", 
            (age_months >= 24 & age_months <= 59) ~ "24 to 59 months", 
            (age_months >= 60 & age_months <= 143) ~ "5 to 11 years", 
            (age_months >= 144 & age_months <= 179 & gender == "Female") ~ 
                "12 to 14 years(girls)", 
            (age_months >= 144 & age_months <= 179 & gender == "Male") ~ 
                "12 to 14 years(boys)", 
            (age_months >= 180 & gender == "Female") ~ 
                ">= 15 years (girls)",
            (age_months >= 180 & gender == "Male") ~ 
                ">= 15 years (boys)") %>% 
            factor(levels = c(
                "3 to 5 months", "6 to 23 months", "24 to 59 months", 
                "5 to 11 years", "12 to 14 years(girls)", 
                "12 to 14 years(boys)",">= 15 years (girls)", 
                ">= 15 years (boys)")), 
        age_cat_2 = case_when(
            (age_months >= 6 & age_months <= 59) ~ "6 to 59 months", 
            (age_months < 6) ~ "< 6 months", 
            (age_months > 59) ~ "> 59 months"), 
        exbf_4mths_older_chn = case_when(
            age_months <= 48 ~ exbf_4mths_older_chn ), 
        history_other = toupper(history_other),
        hx_scd = case_when(
            str_detect(history, "SCD") ~ "Yes", 
            str_detect(history_other, "SCD") ~ "Yes",
            str_detect(history, "SICKLE") ~ "Yes", 
            str_detect(history_other, "SICKLE") ~ "Yes",
            TRUE ~ "No"),
        hx_chd = case_when(
            str_detect(history, "HEART") ~ "Yes", 
            str_detect(history_other, "HEART") ~ "Yes",
            str_detect(history, "TOF") ~ "Yes", 
            str_detect(history_other, "TOF") ~ "Yes",
            str_detect(history, "PULMONARY STENOSIS") ~ "Yes", 
            str_detect(history_other, "PULMONARY STENOSIS") ~ "Yes",
            TRUE ~ "No"), 
        hx_hiv = case_when(
            str_detect(history, "HIV") ~ "Yes", 
            str_detect(history_other, "HIV") ~ "Yes",
            str_detect(history, "RETRO") ~ "Yes", 
            str_detect(history_other, "RETRO") ~ "Yes",
            str_detect(history, "RVI") ~ "Yes", 
            str_detect(history_other, "RVI") ~ "Yes",
            TRUE ~ "No"), 
        hx_dm = case_when(
            str_detect(history, "DIAB") ~ "Yes", 
            str_detect(history_other, "DIAB") ~ "Yes",
            str_detect(history, "DM") ~ "Yes", 
            str_detect(history_other, "RDM") ~ "Yes",
            TRUE ~ "No"),
        hx_malignancy = case_when(
            str_detect(history, "WILM") ~ "Yes", 
            str_detect(history_other, "WILM") ~ "Yes",
            str_detect(history, "MALIG") ~ "Yes", 
            str_detect(history_other, "MALIG") ~ "Yes",
            str_detect(history, "AML") ~ "Yes", 
            str_detect(history_other, "AML") ~ "Yes",
            str_detect(history, "MYELODYSPLASTIC") ~ "Yes", 
            str_detect(history_other, "MYELODYSPLASTIC") ~ "Yes",
            str_detect(history, "CARCINOMA") ~ "Yes", 
            str_detect(history_other, "CARCINOMA") ~ "Yes",
            str_detect(history, "CANCER") ~ "Yes", 
            str_detect(history_other, "CANCER") ~ "Yes",
            str_detect(history, "CRANIOPHARYNGIOMA") ~ "Yes", 
            str_detect(history_other, "CRANIOPHARYNGIOMA") ~ "Yes",
            str_detect(history, "HAMARTOMA") ~ "Yes", 
            str_detect(history_other, "HAMARTOMA") ~ "Yes",
            str_detect(history, "RHABDOMYOSRACOMA") ~ "Yes", 
            str_detect(history_other, "RHABDOMYOSRACOMA") ~ "Yes",
            str_detect(history, "LYMPHOMA") ~ "Yes", 
            str_detect(history_other, "LYMPHOMA") ~ "Yes",
            str_detect(history, "TUMOUR") ~ "Yes", 
            str_detect(history_other, "TUMOUR") ~ "Yes",
            TRUE ~ "No"), 
        hx_ckd = case_when(
            str_detect(history, "CKD") ~ "Yes", 
            str_detect(history_other, "CKD") ~ "Yes",
            str_detect(history, "CHRONIC KIDNEY DISEASE") ~ "Yes", 
            str_detect(history_other, "CHRONIC KIDNEY DISEASE") ~ "Yes",
            str_detect(history, "ESRD") ~ "Yes", 
            str_detect(history_other, "ESRD") ~ "Yes",
            str_detect(history, "NEPHROTIC") ~ "Yes", 
            str_detect(history_other, "NEPHROTIC") ~ "Yes",
            TRUE ~ "No"),
        hx_asthma = case_when(
            str_detect(history, "ASTHMA") ~ "Yes", 
            str_detect(history_other, "ASTHMA") ~ "Yes",
            TRUE ~ "No"),
        hx_cerb_palsy = case_when(
            str_detect(history, "PALSY") ~ "Yes", 
            str_detect(history_other, "PALSY") ~ "Yes",
            TRUE ~ "No"), 
        hx_epilapsy = case_when(
            str_detect(history, "EPILEPSY") ~ "Yes", 
            str_detect(history_other, "EPILEPSY") ~ "Yes",
            TRUE ~ "No"), 
        hx_ftt = case_when(
            str_detect(history, "FTT") ~ "Yes", 
            str_detect(history_other, "FTT") ~ "Yes",
            str_detect(history, "FAILURE TO THRIVE") ~ "Yes", 
            str_detect(history_other, "FAILURE TO THRIVE") ~ "Yes",
            TRUE ~ "No"), 
        hx_g6pd = case_when(
            str_detect(history, "G6PD") ~ "Yes", 
            str_detect(history_other, "G6PD") ~ "Yes",
            TRUE ~ "No"),
        hx_hemophilia = case_when(
            str_detect(history, "HEMOPHILIA") ~ "Yes", 
            str_detect(history_other, "HEMOPHILIA") ~ "Yes",
            TRUE ~ "No"),
        hx_heri_sphero = case_when(
            str_detect(history, "HEREDITARY SPHEROCYTOSIS") ~ "Yes", 
            str_detect(history_other, "HEREDITARY SPHEROCYTOSIS") ~ "Yes",
            TRUE ~ "No"), 
        hx_hirschprung = case_when(
            str_detect(history, "HIRSCHSPRUNG") ~ "Yes", 
            str_detect(history_other, "HIRSCHSPRUNG") ~ "Yes",
            TRUE ~ "No"), 
        hx_cld = case_when(
            str_detect(history, "LIVER DISEASE") ~ "Yes", 
            str_detect(history_other, "LIVER DISEASE") ~ "Yes",
            TRUE ~ "No"), 
        hx_malnutrition = case_when(
            str_detect(history, "MALNUTRITION") ~ "Yes", 
            str_detect(history_other, "MALNUTRITION") ~ "Yes",
            str_detect(history, "WASTED") ~ "Yes", 
            str_detect(history_other, "WASTED") ~ "Yes",
            str_detect(history, "WT/HT <-3SD") ~ "Yes", 
            str_detect(history_other, "WT/HT <-3SD") ~ "Yes",
            TRUE ~ "No"),
        hx_ptb = case_when(
            str_detect(history, "PTB") ~ "Yes", 
            str_detect(history_other, "PTB") ~ "Yes",
            TRUE ~ "No"), 
        hx_seizure = case_when(
            str_detect(history, "SEIZURE") ~ "Yes", 
            str_detect(history_other, "SEIZURE") ~ "Yes",
            TRUE ~ "No"), 
        hx_thalasemia = case_when(
            str_detect(history, "THALASSAEMIA") ~ "Yes", 
            str_detect(history_other, "THALASSAEMIA") ~ "Yes",
            TRUE ~ "No"), 
        adm_clinical_features = toupper(adm_clinical_features),
        pres_fever = case_when(
            str_detect(adm_clinical_features, "FEVER") ~ "Yes",
            TRUE ~ "No"), 
        pres_weakness = case_when(
            str_detect(adm_clinical_features, "WEAKNESS") ~ "Yes",
            str_detect(adm_clinical_features, "PARAPARESIS") ~ "Yes",
            TRUE ~ "No"), 
        pres_seizure = case_when(
            str_detect(adm_clinical_features, "SEIZURE") ~ "Yes",
            str_detect(adm_clinical_features, "CONVULSION") ~ "Yes",
            TRUE ~ "No"), 
        pres_abd_dist = case_when(
            str_detect(adm_clinical_features, "ABDOMINAL DISTENSION") ~ "Yes",
            TRUE ~ "No"), 
        pres_constipation = case_when(
            str_detect(adm_clinical_features, "CONSTIPATION") ~ "Yes",
            TRUE ~ "No"), 
        pres_abd_pain = case_when(
            str_detect(adm_clinical_features, "ABDOMINAL PAIN") ~ "Yes",
            TRUE ~ "No"), 
        pres_bld_stool = case_when(
            str_detect(adm_clinical_features, "BLOODY STOOLS") ~ "Yes",
            str_detect(adm_clinical_features, "BLOODY MUCOID STOOLS") ~ "Yes",
            str_detect(adm_clinical_features, "MELAENA") ~ "Yes",
            TRUE ~ "No"), 
        pres_dark_urine = case_when(
            str_detect(adm_clinical_features, "DARK URINE") ~ "Yes",
            TRUE ~ "No"), 
        pres_vomiting = case_when(
            str_detect(adm_clinical_features, "VOMITING") ~ "Yes",
            TRUE ~ "No"), 
        pres_diarrhoea = case_when(
            str_detect(adm_clinical_features, "DIARRHOEA") ~ "Yes",
            TRUE ~ "No"), 
        pres_jaundice = case_when(
            str_detect(adm_clinical_features, "JAUNDICE") ~ "Yes",
            TRUE ~ "No"), 
        pres_pallor = case_when(
            str_detect(adm_clinical_features, "PALLOR") ~ "Yes",
            TRUE ~ "No"), 
        pres_headache = case_when(
            str_detect(adm_clinical_features, "HEADACHE") ~ "Yes",
            TRUE ~ "No"),
        pres_dev_reg = case_when(
            str_detect(adm_clinical_features, "DEVELOPMENTAL REGRESSION") ~ "Yes",
            TRUE ~ "No"), 
        pres_dysphagia = case_when(
            str_detect(adm_clinical_features, "DYSPHAGIA") ~ "Yes",
            str_detect(adm_clinical_features, "DIFFICULTY SWALLOWING") ~ "Yes",
            TRUE ~ "No"), 
        pres_facial_swell = case_when(
            str_detect(adm_clinical_features, "FACIAL SWELLING") ~ "Yes",
            TRUE ~ "No"), 
        pres_fast_breath = case_when(
            str_detect(adm_clinical_features, "FAST BREATHING") ~ "Yes",
            TRUE ~ "No"), 
        pres_rash = case_when(
            str_detect(adm_clinical_features, "RASH") ~ "Yes",
            str_detect(adm_clinical_features, "MULTIPLE CUTANEOUS NODULES") ~ "Yes",
            TRUE ~ "No"), 
        pres_red_eyes = case_when(
            str_detect(adm_clinical_features, "CONJUNCTIVITIS") ~ "Yes",
            TRUE ~ "No"), 
        pres_leg_pain = case_when(
            str_detect(adm_clinical_features, "LEG PAIN") ~ "Yes",
            TRUE ~ "No"), 
        pres_chest_pain = case_when(
            str_detect(adm_clinical_features, "CHEST PAIN") ~ "Yes",
            TRUE ~ "No"), 
        pres_cough = case_when(
            str_detect(adm_clinical_features, "COUGH") ~ "Yes",
            TRUE ~ "No"), 
        pres_cyanosis = case_when(
            str_detect(adm_clinical_features, "CYANOSIS") ~ "Yes",
            TRUE ~ "No"), 
        pres_thrush = case_when(
            str_detect(adm_clinical_features, "THRUSH") ~ "Yes",
            TRUE ~ "No"), 
        pres_dyspnoea = case_when(
            str_detect(adm_clinical_features, "RESPIRATORY DIFFICULTY") ~ "Yes",
            TRUE ~ "No"), 
        pres_palpitation = case_when(
            str_detect(adm_clinical_features, "PALPITATION") ~ "Yes",
            TRUE ~ "No"), 
        pres_swelling = case_when(
            str_detect(adm_clinical_features, "SWELLING") ~ "Yes",
            TRUE ~ "No"), 
        pres_joint_pain = case_when(
            str_detect(adm_clinical_features, "JOINT PAIN") ~ "Yes",
            str_detect(adm_clinical_features, "KNEE PAIN") ~ "Yes",
            TRUE ~ "No"),
        pres_throat_pain = case_when(
            str_detect(adm_clinical_features, "SORE THROAT") ~ "Yes",
            TRUE ~ "No"), 
        pres_epistaxis = case_when(
            str_detect(adm_clinical_features, "EPISTAXIS") ~ "Yes",
            TRUE ~ "No"),
        pres_hpt = case_when(
            str_detect(adm_clinical_features, "HYPERTENSION") ~ "Yes",
            TRUE ~ "No"),
        pres_imp_conscious = case_when(
            str_detect(adm_clinical_features, "IMPAIRED CONSCIOUS") ~ "Yes",
            TRUE ~ "No"), 
        pres_meningitis = case_when(
            str_detect(adm_clinical_features, "MENINGITIS") ~ "Yes",
            TRUE ~ "No"), 
        pres_noise_breath = case_when(
            str_detect(adm_clinical_features, "NOISY BREATHING") ~ "Yes",
            str_detect(adm_clinical_features, "STRIDOR") ~ "Yes",
            TRUE ~ "No"), 
        pres_wasting = case_when(
            str_detect(adm_clinical_features, "WASTING") ~ "Yes",
            str_detect(adm_clinical_features, "WEIGHT LOSS") ~ "Yes",
            TRUE ~ "No"), 
        pres_bodily_pains = case_when(
            str_detect(adm_clinical_features, "GENERALIZED BODY PAIN") ~ "Yes",
            TRUE ~ "No"), 
        pres_poor_feeding = case_when(
            str_detect(adm_clinical_features, "POOR APPETITE") ~ "Yes",
            str_detect(adm_clinical_features, "POOR FEEDING") ~ "Yes",
            TRUE ~ "No"),
        pres_mass = case_when(
            str_detect(adm_clinical_features, "MASS") ~ "Yes",
            TRUE ~ "No"), 
        pres_rectal_prolapse = case_when(
            str_detect(adm_clinical_features, "RECTAL PROLAPSE") ~ "Yes",
            TRUE ~ "No"),
        pres_urinary_symp = case_when(
            str_detect(adm_clinical_features, "URINARY") ~ "Yes",
            str_detect(adm_clinical_features, "OLIGURIA") ~ "Yes",
            TRUE ~ "No"), 
        pres_shock = case_when(
            str_detect(adm_clinical_features, "SHOCK") ~ "Yes",
            TRUE ~ "No"), 
        pres_poison = case_when(
            str_detect(adm_clinical_features, "INGESTION") ~ "Yes",
            TRUE ~ "No"),
        pres_rta = case_when(
            str_detect(adm_clinical_features, "RTA") ~ "Yes",
            TRUE ~ "No"), 
        hx_others = case_when(
            hx_dm == "Yes" ~ "Yes", 
            hx_ckd == "Yes" ~ "Yes", 
            hx_asthma == "Yes" ~ "Yes", 
            hx_cerb_palsy == "Yes" ~ "Yes", 
            hx_epilapsy == "Yes" ~ "Yes",   
            hx_hemophilia == "Yes" ~ "Yes",
            hx_heri_sphero == "Yes" ~ "Yes", 
            hx_hirschprung == "Yes" ~ "Yes", 
            hx_cld == "Yes" ~ "Yes", 
            hx_ptb == "Yes" ~ "Yes", 
            hx_seizure == "Yes" ~ "Yes", 
            hx_thalasemia == "Yes" ~ "Yes",
            TRUE ~ "No"), 
        pres_others = case_when(
            pres_cyanosis == "Yes" ~ "Yes", 
            pres_poison == "Yes" ~ "Yes", 
            pres_imp_conscious == "Yes" ~ "Yes", 
            pres_mass == "Yes" ~ "Yes", 
            pres_dysphagia == "Yes" ~ "Yes", 
            pres_noise_breath == "Yes" ~ "Yes", 
            pres_poor_feeding == "Yes" ~ "Yes", 
            pres_throat_pain == "Yes" ~ "Yes", 
            pres_urinary_symp == "Yes" ~ "Yes", 
            pres_wasting == "Yes" ~ "Yes", 
            pres_bodily_pains == "Yes" ~ "Yes", 
            pres_constipation == "Yes" ~ "Yes", 
            pres_dev_reg == "Yes" ~ "Yes", 
            pres_epistaxis == "Yes" ~ "Yes", 
            pres_facial_swell == "Yes" ~ "Yes", 
            pres_hpt == "Yes" ~ "Yes", 
            pres_leg_pain == "Yes" ~ "Yes", 
            pres_meningitis == "Yes" ~ "Yes", 
            pres_rectal_prolapse == "Yes" ~ "Yes", 
            pres_red_eyes == "Yes" ~ "Yes", 
            pres_rta == "Yes" ~ "Yes", 
            pres_shock == "Yes" ~ "Yes", 
            pres_thrush == "Yes" ~ "Yes", 
            TRUE ~ "No"))
Joining with `by = join_by(study_id)`
Code
labelled::var_label(df_anemia_ready) <- 
    list(
        anemia ="Anemia Present", 
        rdw_cat = "Categorised RDW", 
        mcv_cat = "categorised MCV", 
        died = "Patient Died", 
        rbc_transfused = "Transfused Blood", 
        immun_status = "Immunity Status",
        deworm_6mths_2 = "Dewormed in the past 6 months", 
        rdt_positive = "RDT Positive", 
        mps_positive = "Malaria parasites positive", 
        mal_prev_use = "Use of Malatria prevention method", 
        mal_prev_repellent = "Prevention: Repellent", 
        mal_prev_clothes = "Prevention: Clothes",  
        mal_prev_spray_coil = "Prevention: Spray or Coil",
        mal_prev_itn = "Prevention: ITN", 
        bld_loss_3mths_2 = "Blood loss (past 3 months)", 
        age_months = "Age (Months)", 
        dura_hosp_stay = "Duration of Hospital Stay", 
        picu_required = "PICU admision required", 
        txn_required = "Transfusion required", 
        iron_supp_3mths = "Iron supp. past 3 months", 
        exbf_4mths_older_chn = 
            "Excl. Breastfeeding (4 months) in older child", 
        eat_iron_veges = "Eats iron containing vegetables", 
        family_income = "Family Income",  
        paternal_education = "Father's educational level",
        maternal_education = "Mother's educational level", 
        residence = "Residence type",  
        gender = "Sex", 
        bld_film_done= "Blood film done", 
        bf_ida = "Blood Film: IDA", 
        bf_scd = "Blood Film: SCD", 
        bf_infection = "Blood Film: Infection", 
        bf_liver = "Blood Film: Liver pathology", 
        bf_renal = "Blood Film: Renal pathology", 
        bf_malignancy = "Blood Film: Malignancy", 
        bf_hemolytic = "Blood Film: Hemolysis", 
        bf_malaria = "Blood Film: Malaria", 
        bf_inflamation = "Blood Film: Inflamation", 
        ida = "Iron Defecienvy Anemia", 
        malaria = "Malaria", 
        scd = "Sicle cell Disease", 
        g6pd = "G6PD",
        anemia_of_malig = "Anemia of malignacy", 
        anemia_of_chr_dx = "Anemia of Chronic Disease",
        diag_bronchiolitis = "Diagnosis: Bronchiolitis",
        diag_gastroenteritis = "Diagnosis: Gastroenteritis", 
        diag_Liver_pathology = "Diagnosis: Liver Pathology",
        diag_nephropathy = "Diagnosis: Nephropathy", 
        diag_malaria = "Diagnosis: malaria",
        diag_sepsis = "Diagnosis: Sepsis",
        diag_urti   = "Diagnosis: URTI",
        diag_lrti   = "Diagnosis: LRTI", 
        diag_cardiac = "Diagnosis: Cardiopathy",
        diag_malignancy = "Diagnosis: malignancy", 
        diag_others = "Diagnosis: Others", 
        diag_cns    = "Diagnosis: CNS",
        diag_poison = "Diagnosis: Poisons",
        diag_dka    = "Diagnosis: DKA", 
        diag_rbc_abnormalities = "Diagnosis: Hemoglobinopathies",
        diag_hiv    = "Diagnosis: HIV", 
        diag_surgical = "Diagnosis: Surgical", 
        age_cat     = "Categorised Age", 
        age_cat_2   = "Categorised Age (6-59)", 
        malnutrition = "Malnutrition", 
        immunization_status = "Immunization Status", 
        hx_scd = "History: SCD",
        hx_chd = "History: CHD",
        hx_hiv = "History: HIV", 
        hx_dm = "History: Diabetes Mellitus",
        hx_malignancy = "History: Malignancy",
        hx_ckd = "History: Chronic Kidney Disease", 
        hx_asthma = "History: Asthma", 
        hx_cerb_palsy = "Cerebral Palsy",
        hx_epilapsy = "History: Epilepsy",
        hx_ftt = "History: Failure to thrive",
        hx_g6pd = "History: G6PD",
        hx_hemophilia = "History: Hemophelia", 
        hx_heri_sphero = "History: Heriditary Spherocytosis", 
        hx_hirschprung = "History: Hirschprung's Disease",
        hx_cld = "History: Chronic Liver Disease",
        hx_malnutrition = "History: Malnutrition",
        hx_ptb = "History: Tuberculosis",
        hx_seizure = "History: Seizure disorder",
        hx_thalasemia = "History: Thalasemia", 
        date_of_admission ="Date of Admission", 
        date_of_birth = "Date of Birth", 
        bld_loss_3mths = "Source: Blood Loss", 
        transfusion_3mths = "Transfusion: 3 Months", 
        study_id = "Study ID", 
        history = "History", 
        history_other = "Other History", 
        mal_prev = "Malaria Prevention Measure", 
        deworm_6mths = "Dewormed (past 6 months)", 
        adm_clinical_features = "Admission clinical features", 
        hb = "Hemoglobin (g/dl)", 
        mcv = "Mean Caposcular Volume", 
        rdw_sd = "Red Cell Distribution Width (SD)", 
        rdw_cv = "Red Cell Distribution Width (CV)", 
        wbc_x109 = "White Cell Count (x109)", 
        platelet = "Platelet Count", 
        reticulocyte_count = "Reticulocyte Count",
        blood_film_comment = "Blood Film Comment", 
        rdt = "RDT", 
        malaria_parasites = "Malaria Parasites", 
        other_laboratory_findings = "Other Laboratory Findings", 
        anemia_type = "Type of Anemia", 
        pres_fever  = "Presentation: Fever", 
        pres_weakness   = "Presentation: Weakness",
        pres_seizure = "Presentation: Seizure",
        pres_abd_dist = "Presentation: Abdominal Distention",
        pres_constipation = "Presentation: Constipation",
        pres_abd_pain = "Presentation: Abdominal Pain",
        pres_bld_stool = "Presentation: Bloody Stool",
        pres_dark_urine = "Presentation: Dark Urine",
        pres_vomiting = "Presentation: Vomiting",   
        pres_diarrhoea = "Presentation: Diarrhoea",
        pres_jaundice = "Presentation: Jaundice",
        pres_pallor = "Presentation: Pallor",
        pres_headache = "Presentation: Headache",
        pres_dev_reg = "Presentation: Developmental regression",
        pres_dysphagia   = "Presentation: Dysphagia",
        pres_fast_breath = "Presentation: Fast Breathing",
        pres_rash = "Presentation: Rash",
        pres_red_eyes = "Presentation: Red Eyes",
        pres_leg_pain = "Presentation: Leg Pain",
        pres_chest_pain = "Presentation: Chest Pain",
        pres_cough  = "Presentation: Cough",
        pres_cyanosis = "Presentation: Cyanosis",
        pres_thrush = "Presentation: Oral Thrush",
        pres_dyspnoea = "Presentation: Dyspnoea",
        pres_palpitation = "Presentation: Palpitations",
        pres_swelling = "Presentation: Swelling",
        pres_joint_pain = "Presentation: Joint Pain",
        pres_throat_pain = "Presentation: Throat Pain", 
        pres_epistaxis  = "Presentation: Epistaxis",
        pres_hpt = "Presentation: Hypertension",
        pres_imp_conscious  = "Presentation: Impaired Consciousness",
        pres_meningitis = "Presentation: Meningitis",
        pres_noise_breath = "Presentation: Noisy Breathing",
        pres_wasting = "Presentation: Wasting",
        pres_bodily_pains = "Presentation: Bodily Pains",
        pres_poor_feeding = "Presentation: Poor Feeding",
        pres_mass = "Presentation: Mass",
        pres_rectal_prolapse = "Presentation: Rectal Prolapse",
        pres_urinary_symp = "Presentation: Urinary Symptoms",
        pres_shock  = "Presentation: Shock", 
        pres_poison = "Presentation: Poison Ingestion",
        pres_rta = "Presentation: RTA", 
        hx_others = "History: Others", 
        pres_others = "Presentation: Others") 

Table 1

Code
gtsummary::reset_gtsummary_theme()
gtsummary::theme_gtsummary_compact()
Setting theme "Compact"
Code
table_one <- 
    df_anemia_ready %>% 
    select(
        age_months, died, gender, residence, maternal_education, 
        exbf_4mths_older_chn, family_income, 
        
        hx_malnutrition, hx_scd, hx_chd, hx_g6pd,
        hx_malignancy, hx_hiv, hx_ftt, hx_others,
        
        pres_fever, pres_weakness, pres_fast_breath, pres_dyspnoea, 
        pres_vomiting, pres_swelling, pres_diarrhoea, pres_palpitation, 
        pres_jaundice, pres_seizure, pres_cough, pres_dark_urine, 
        pres_abd_pain, pres_pallor, pres_joint_pain, pres_bld_stool, 
        pres_abd_dist, pres_chest_pain, pres_headache, pres_rash, 
        pres_others,
        
        wbc_x109, rdw_sd, rdt, 
        
        diag_malignancy, diag_lrti, diag_Liver_pathology, 
        diag_sepsis, diag_hiv, malnutrition, 
        
        picu_required, rbc_transfused, dura_hosp_stay) %>% 
    gtsummary::tbl_summary(by = died) %>% 
    gtsummary::add_overall(last = TRUE) %>% 
    gtsummary::add_p(
        pvalue_fun = function(x) gtsummary::style_pvalue(x, digits = 3)) %>% 
    gtsummary::bold_p() %>% 
    gtsummary::bold_labels()

table_one
Characteristic No
N = 2881
Yes
N = 301
Overall
N = 3181
p-value2
Age (Months) 42 (14, 94) 18 (8, 45) 38 (14, 93) 0.015
Sex


0.822
    Female 131 (45%) 13 (43%) 144 (45%)
    Male 157 (55%) 17 (57%) 174 (55%)
Residence type


0.429
    Rural 113 (39%) 14 (47%) 127 (40%)
    Urban 175 (61%) 16 (53%) 191 (60%)
Mother's educational level


0.434
    None 30 (10%) 2 (6.7%) 32 (10%)
    Primary 121 (42%) 9 (30%) 130 (41%)
    Secondary 89 (31%) 13 (43%) 102 (32%)
    Tertiary 48 (17%) 6 (20%) 54 (17%)
Excl. Breastfeeding (4 months) in older child 95 (61%) 11 (48%) 106 (59%) 0.234
    Unknown 132 7 139
Family Income


0.874
    Low 195 (68%) 22 (73%) 217 (68%)
    Middle 81 (28%) 7 (23%) 88 (28%)
    High 12 (4.2%) 1 (3.3%) 13 (4.1%)
History: Malnutrition 41 (14%) 8 (27%) 49 (15%) 0.105
History: SCD 40 (14%) 1 (3.3%) 41 (13%) 0.149
History: CHD 15 (5.2%) 3 (10%) 18 (5.7%) 0.235
History: G6PD 11 (3.8%) 2 (6.7%) 13 (4.1%) 0.352
History: Malignancy 7 (2.4%) 3 (10%) 10 (3.1%) 0.058
History: HIV 7 (2.4%) 1 (3.3%) 8 (2.5%) 0.552
History: Failure to thrive 3 (1.0%) 2 (6.7%) 5 (1.6%) 0.072
History: Others 21 (7.3%) 2 (6.7%) 23 (7.2%) >0.999
Presentation: Fever 160 (56%) 22 (73%) 182 (57%) 0.061
Presentation: Weakness 103 (36%) 15 (50%) 118 (37%) 0.125
Presentation: Fast Breathing 88 (31%) 19 (63%) 107 (34%) <0.001
Presentation: Dyspnoea 87 (30%) 19 (63%) 106 (33%) <0.001
Presentation: Vomiting 59 (20%) 2 (6.7%) 61 (19%) 0.067
Presentation: Swelling 48 (17%) 4 (13%) 52 (16%) 0.798
Presentation: Diarrhoea 41 (14%) 3 (10%) 44 (14%) 0.781
Presentation: Palpitations 32 (11%) 10 (33%) 42 (13%) 0.002
Presentation: Jaundice 24 (8.3%) 8 (27%) 32 (10%) 0.005
Presentation: Seizure 26 (9.0%) 6 (20%) 32 (10%) 0.100
Presentation: Cough 25 (8.7%) 2 (6.7%) 27 (8.5%) >0.999
Presentation: Dark Urine 22 (7.6%) 5 (17%) 27 (8.5%) 0.157
Presentation: Abdominal Pain 23 (8.0%) 0 (0%) 23 (7.2%) 0.146
Presentation: Pallor 15 (5.2%) 3 (10%) 18 (5.7%) 0.235
Presentation: Joint Pain 13 (4.5%) 0 (0%) 13 (4.1%) 0.620
Presentation: Bloody Stool 9 (3.1%) 0 (0%) 9 (2.8%) >0.999
Presentation: Abdominal Distention 7 (2.4%) 0 (0%) 7 (2.2%) >0.999
Presentation: Chest Pain 6 (2.1%) 0 (0%) 6 (1.9%) >0.999
Presentation: Headache 5 (1.7%) 0 (0%) 5 (1.6%) >0.999
Presentation: Rash 4 (1.4%) 1 (3.3%) 5 (1.6%) 0.393
Presentation: Others 35 (12%) 2 (6.7%) 37 (12%) 0.552
White Cell Count (x109) 12 (8, 17) 12 (10, 20) 12 (8, 17) 0.454
Red Cell Distribution Width (SD) 40 (37, 48) 47 (41, 50) 41 (37, 48) 0.004
RDT


0.781
    Negative 247 (86%) 27 (90%) 274 (86%)
    Positive 41 (14%) 3 (10%) 44 (14%)
Diagnosis: malignancy 15 (5.2%) 4 (13%) 19 (6.0%) 0.091
Diagnosis: LRTI 28 (9.7%) 3 (10%) 31 (9.7%) >0.999
Diagnosis: Liver Pathology 3 (1.0%) 4 (13%) 7 (2.2%) 0.002
Diagnosis: Sepsis 31 (11%) 9 (30%) 40 (13%) 0.006
Diagnosis: HIV 8 (2.8%) 1 (3.3%) 9 (2.8%) 0.595
Malnutrition 41 (14%) 8 (27%) 49 (15%) 0.105
PICU admision required 6 (2.1%) 7 (23%) 13 (4.1%) <0.001
Transfused Blood 66 (23%) 10 (33%) 76 (24%) 0.203
Duration of Hospital Stay 6 (3, 11) 4 (3, 6) 6 (3, 10) 0.166
1 Median (Q1, Q3); n (%)
2 Wilcoxon rank sum test; Pearson’s Chi-squared test; Fisher’s exact test
Code
file.remove("./Tables/table_one.docx")
[1] TRUE
Code
table_one %>% 
    gtsummary::as_gt() %>% 
    gt::gtsave("./Tables/table_one.docx")

Multivariate

Code
table_two <-
    df_anemia_ready %>% 
    mutate(died2 = unclass(died)-1) %>%
    select(
        died2, age_months, hx_malnutrition, hx_scd, hx_malignancy, 
        hx_ftt, pres_fever, pres_weakness, pres_fast_breath,
        pres_vomiting,pres_palpitation, pres_seizure, 
        pres_dark_urine, rdw_sd, diag_Liver_pathology, 
        diag_sepsis, picu_required, dura_hosp_stay) %>%
    glm(died2 ~ ., data = ., family=poisson()) %>%
    gtsummary::tbl_regression(
        pvalue_fun = function(x) gtsummary::style_pvalue(x, digits = 3),
        exponentiate = T) %>% 
    # gtsummary::modify_header(
    #         estimate ~ "**IRR**",
    #         label ~ "**Variable**") %>% 
    gtsummary::bold_p() %>% 
    gtsummary::bold_labels() 

table_two
Characteristic IRR 95% CI p-value
Age (Months) 1.00 0.99, 1.01 0.605
History: Malnutrition


    No
    Yes 3.37 1.17, 9.40 0.021
History: SCD


    No
    Yes 0.33 0.02, 2.13 0.328
History: Malignancy


    No
    Yes 7.01 1.29, 30.0 0.013
History: Failure to thrive


    No
    Yes 1.87 0.26, 8.65 0.462
Presentation: Fever


    No
    Yes 1.18 0.46, 3.16 0.740
Presentation: Weakness


    No
    Yes 1.17 0.47, 2.79 0.733
Presentation: Fast Breathing


    No
    Yes 2.44 0.95, 6.54 0.067
Presentation: Vomiting


    No
    Yes 0.77 0.12, 2.96 0.742
Presentation: Palpitations


    No
    Yes 2.18 0.77, 6.03 0.136
Presentation: Seizure


    No
    Yes 2.12 0.69, 5.87 0.163
Presentation: Dark Urine


    No
    Yes 1.18 0.28, 4.09 0.808
Red Cell Distribution Width (SD) 1.03 0.98, 1.07 0.206
Diagnosis: Liver Pathology


    No
    Yes 10.2 2.00, 47.9 0.004
Diagnosis: Sepsis


    No
    Yes 3.55 1.26, 9.61 0.013
PICU admision required


    No
    Yes 4.64 1.58, 13.0 0.004
Duration of Hospital Stay 0.93 0.86, 0.98 0.033
Abbreviations: CI = Confidence Interval, IRR = Incidence Rate Ratio
Code
file.remove("./Tables/table_two.docx")
[1] TRUE
Code
table_two %>% 
    gtsummary::as_gt() %>% 
    gt::gtsave("./Tables/table_two.docx")

Mortality table

Code
gtsummary::theme_gtsummary_eda()
Setting theme "Exploratory Data Analysis"
Code
table_three <-
    df_anemia_ready %>% 
    filter(died == "Yes") %>% 
    mutate(
        los_cat = case_when(
        dura_hosp_stay <= 1 ~ "1 day", 
        dura_hosp_stay >1 & dura_hosp_stay <=7 ~ "2 to 7 days",
        dura_hosp_stay > 7 ~ "8 days or more")) %>% 
    select(died, age_months, los_cat, discharge_diagnosis_upper) %>%
    gtsummary::tbl_summary() %>% 
    gtsummary::bold_labels()

table_three
Characteristic N = 301
Patient Died 30 (100.0%)
Age (Months)
    Median (Q1, Q3) 18 (8, 45)
    Mean (SD) 41 (52)
    Min, Max 2, 164
los_cat
    1 day 3 (10.0%)
    2 to 7 days 20 (66.7%)
    8 days or more 7 (23.3%)
discharge_diagnosis_upper
    ACUTE LIVER FAILURE 4 (13.3%)
    AML 1 (3.33%)
    CEREBRAL MALARIA 1 (3.33%)
    CRANIOPHARYNGIOMA 1 (3.33%)
    CYANOTIC CONGENITAL HEART DISEASE 1 (3.33%)
    FEBRILE ENCEPHALOPATHY 1 (3.33%)
    HIV 1 (3.33%)
    HYPOVOLEMIC SHOCK 1 (3.33%)
    MENINGOENCEPHALITIS 1 (3.33%)
    NEPHROTIC SYNDROME 1 (3.33%)
    NEUROFIBROMATOSIS 1 (3.33%)
    PNEUMONIA 3 (10.0%)
    PTB 1 (3.33%)
    SAM 1 (3.33%)
    SCD WITH CVA 1 (3.33%)
    SEPSIS 8 (26.7%)
    VIRAL EXANTHEM 1 (3.33%)
    WILMS TUMOUR 1 (3.33%)
1 n (%)
Code
file.remove("./Tables/table_three.docx")
[1] TRUE
Code
table_three %>% 
    gtsummary::as_gt() %>% 
    gt::gtsave("./Tables/table_three.docx")

Graph of causes of death

Code
df_anemia_ready %>% 
    filter(died == "Yes") %>% 
    select(discharge_diagnosis_upper) %>%
    mutate(discharge_diagnosis_upper = case_when(
        discharge_diagnosis_upper == "WILMS TUMOUR" ~"WILM'S TUMOUR",
        discharge_diagnosis_upper == "SCD WITH CVA" ~ "SICKLE CELL DISEASE WITH STROKE",
        discharge_diagnosis_upper == "SAM" ~ "SEVER ACUTE MALNUTRITION",
        discharge_diagnosis_upper == "PTB" ~ "PULMONARY TUBERCULOSIS",
        discharge_diagnosis_upper == "AML" ~ "ACUTE MYLOID LEUKEMIA",
        TRUE ~ discharge_diagnosis_upper)) %>% 
    ggplot(aes(x = fct_infreq(discharge_diagnosis_upper))) + 
    geom_bar(position = "identity", col = "steelblue", fill = "steelblue")+
    labs(x = NULL, y ="Frequency")+
    theme_light()+
    coord_flip()