I have a dataframe that contains message_type, numerator and week_of. Sliced dput output is below. I want to use tbl_summary to display the sum of numerator for each message_type but can’t figure out how to do that.
Desired output would be along the lines of:
Staff Message 56 (20%)
Patient Calls 17 (12%)
etc.
tried this but it’s displaying number of rows for each message_type
volume |>
select(message_type, numerator) |>
tbl_summary(type = list(c(numerator) ~ "continuous"),
statistic = list(c(numerator) ~ "{sum}")
)
structure(list(message_type = structure(c(20L, 10L, 17L, 2L,
9L, 12L, 8L, 18L, 19L, 5L, 16L, 11L, 4L, 1L, 6L, 15L, 14L, 13L,
3L, 7L), levels = c("CC Charts", "Charts", "E-Prescribing Errors",
"Hospital ADT", "Incomplete Note", "IP Cosign Note", "Letter Queue",
"Open Encounters", "Overdue Rslt", "Patient Calls", "Patient Medical Advice Request",
"Patient Reminder", "Post Mortem Notification", "Referral Message",
"Referral Notification Letter", "Result Notes", "Results", "Rx Auth",
"Rx Response", "Staff Message"), class = "factor"), numerator = c(56,
17, 19, 9, 0, 0, 1, 0, 0, 20, 0, 6, 5, 4, 33, 0, 3, 1, 0, 0),
week_of = structure(c(1690070400, 1690070400, 1690070400,
1690070400, 1690070400, 1690070400, 1690070400, 1690070400,
1690070400, 1690070400, 1690070400, 1690070400, 1690070400,
1690070400, 1690070400, 1690070400, 1690070400, 1690070400,
1690070400, 1690070400), tzone = "UTC", class = c("POSIXct",
"POSIXt"))), row.names = c(NA, -20L), class = "data.frame")