df_sparco_2_clean <-
df_sparco_2 %>%
select(
-c(telephone2, consent_sign, participant_name, consent_person,
first_name, middle_name, last_name, residential, digital_address,
social_family_relations, lhimsno, sparco_i_id, telephone1,
attend_doc)) %>%
janitor::remove_empty(which = c("rows", "cols")) %>%
rename(
minimental_state_comp = minimental_state_examination_adolescents_adults_complete,
demo_comp = demographic_characteristics_complete,
past_int_hx_comp = past_interim_history_complete,
opd_visit_outc_comp = outpatient_visit_outcomes_complete,
goofd_draw_test_comp = goodenough_drawaperson_test_complete,
stroke_risk_comp = stroke_risk_assessment_adolescents_adults_complete,
vascular_risk_comp = vascular_risk_factors_assessment_adolescents_adult_complete,
hamd_comp = hamilton_depression_rating_scale_hamd_adolescents_complete,
qol_eq5d_comp = quality_of_life_eq5d_adolescents_adults_complete,
moca_comp = montreal_cognitive_assessment_moca_adolescents_adu_complete,
ipd_outc_comp = inpatient_visit_outcomes_complete) %>%
mutate(
across(
c(temp:head_circ, mcv_fl, mch_pg, mchc, neut,
plt_103ul, moca_tot_score),
~ifelse(.x < 0, NA, .x)),
across(c(weight, height), ~as.numeric(.x)),
across(sex, ~labelled::to_factor(.x)),
across(c(weight, height), ~ifelse(.x < 0, NA, .x)),
hamd_greater_than_7 = case_when(
hamd_total >= 8 ~ "Yes", hamd_total < 8 ~ "No") %>%
factor(),
hamd_cat = case_when(
hamd_total <= 7 ~ "Normal",
hamd_total <= 17 ~ "Mild",
hamd_total <= 24 ~ "Moderate",
hamd_total >= 25 ~ "Severe") %>%
factor(levels = c("Normal", "Mild", "Moderate", "Severe")),
pulse = ifelse(pulse == 878, 87, pulse),
sat = ifelse(sat >100, 100, sat),
religion = fct_relevel(religion, "Christian", "Muslim"),
scd_test_result_ss_sbthal = fct_recode(
scd_test_result_ss_sbthal,
"S-beta thal" = "S-beta thal zero (nought)",
"S-beta thal" = "S-beta thal plus/minus"),
scd_test_result_ss_sbthal = fct_na_level_to_value(
scd_test_result_ss_sbthal,
extra_levels = "Pending confirmation"),
res_status = fct_relevel(res_status, "Urban", "Semi-urban"),
edu_status = fct_relevel(
edu_status,
"Tertiary", "SHS/Vocational", "JHS", "Basic"),
category_of_patient = fct_relevel(
category_of_patient,
"Adult (18+ years)", "Adolescent (10-17 years)",
"Child (< 10 years)"),
cal_age_recruit_yrs_2 = cal_age_recruit_yrs/10)
df_for_moca <-
df_sparco_2_clean %>%
filter(redcap_event_name == "Enrolment") %>%
select(
moca_tot_score, hamd_greater_than_7, hamd_cat,
category_of_patient, cal_age_recruit_yrs,
cal_age_recruit_mths,cal_age_recruit_yrs_2, sex,
scd_test_result_ss_sbthal, edu_status, religion,
res_status, diag_pathway, using_hydroxyurea,
penicillin_v_prophylaxis, folic_acid,
temp, pulse, resp_rate, sat, sbp, dbp, wbc_103ul, hb_g_dl,
rbc_106ul, mcv_fl, mch_pg, mchc, neut, plt_103ul, hamd_total,
moca_tot_score, eq_5d_health_status) %>%
drop_na(moca_tot_score) %>%
mutate(
moca_less_than_median = case_when(
moca_tot_score < median(moca_tot_score) ~ "Yes",
TRUE ~ "No") %>%
factor()) %>%
droplevels()
labelled::var_label(df_for_moca) <-
list(
eq_5d_health_status = "EQ-5D Health Status",
hamd_cat = "Categorised HAMD",
hamd_total = "Total HAMD",
cal_age_recruit_yrs = "Age (years)",
cal_age_recruit_yrs_2 = "Age(per 10 years)",
cal_age_recruit_mths = "Age (months)",
category_of_patient = "Age category",
sex = "Sex",
scd_test_result_ss_sbthal = "Genotype",
hamd_greater_than_7 = "Depression Status",
edu_status = "Educational status",
religion = "Religion",
res_status = "Residential Status",
diag_pathway = "Diagnosis Pathway",
using_hydroxyurea = "HU Usage",
penicillin_v_prophylaxis = "Penicillin Use",
folic_acid = "Folic Acid Usage",
temp = "Temperature",
pulse = "Pulse",
resp_rate = "Respiratory Rate",
sat = "Oxygen Saturation",
sbp = "Systolic Blood Pressure (mmHg)",
dbp = "Diastolic Blood Pressure (mmHg)",
wbc_103ul = "White Bolld Cell Count (10^-3ul)",
hb_g_dl = "Hemoglobin (g/dl)" ,
rbc_106ul = "Red Blood Cells Count (10^-6ul)",
mcv_fl = "MCV (fl)",
mch_pg = "MCH (pg)",
mchc = "MCHC",
neut = "Neutrophil count",
plt_103ul = "Platelet Count (10^-3ul)",
moca_tot_score = "Total MOCA Score")