I saw an article that I'd like to replicate. They had categorical predictions as the rows, and use N for column 1 and Median of another variable for column 2. I'd like to be able to create a function to get me Median for Column 2.
Sample image

I'm not sure how to get the median at each specific level. I tried group by, but that would only give me median's per higher level.
library(gtsummary)
trial2 <- trial %>% select(stage, grade, ttdeath) %>%
group_by(stage, grade) %>%
mutate(median_ttdeath = median(ttdeath))
