I have a categorical variable (ethnicity) with unknown values, and I am trying to present it with gtsummary so that the proportions are computed separately for known and unknown values
I have managed to get to this stage
But I cannot find a way to calculate the proportion of missing values separately
My code is something along these lines
trial %>%
select(age, response, trt) %>%
tbl_summary(
by = trt,
missing = "if_any",
statistic = list(all_continuous() ~ "{mean} ({sd})",
response~ c("{n} ({p}%)",
"{N_miss} ({p_miss})"),
all_categorical() ~ "{n} ({p}%)"),
)
I did try the solution suggested here (i.e. fct_replace_na
and setting missing = "no"
) but it keeps including the unknown rows in the overall proportions
Thank you