I am trying to differentiate between missing data and “not concerned” cases in gtsummary. For example, if I were to ask, “are you pregnant?” in a survey, men would be “not concerned” and women not answering would be “missing”. Neither missing nor “not concerned” should be included in the denominator but it can be useful to distinguish between those two cases.
Exemple:
library(tidyverse)
library(gtsummary)
tab <- tibble(
sex = c(rep("M", 10), rep("F", 10)),
pregnant = c(rep(NA, 12), rep("0", 6), rep("1", 2))
)
tbl_summary(tab)
Currently gtsummary adds a line displaying the number of missing cases and percentages are displayed among known cases Output from gtsummary.
What I would ideally like to obtain is a second line with the number of "not concerned" Expected output.
So far the solutions I found were:
- Run the tbl_summary() separately for "concerned" population (here among women) and merge tables with tbl_stack(). This solution presents two issues:
- It is long to implement if many questions concern only part of the population (which can be often in surveys).
- The number of missing is displayed correctly but the number of "not concerned" is omitted
- Manually recode "not concerned" cases as "not concerned". However, using that solution, the "not concerned" cases are included in the denominator.
Is there a better solution that those cited above? Is there a way to exclude modalities from the denominator?
Thank you for your help.