I have a continuous variable with a significant proportion of unknowns. My advisor is asking me to put the percentage next to it in the column. This reprex mimics what I am trying to do.
library(tidyverse)
library(gtsummary)
trial %>% # included with gtsummary package
select(trt, age, grade) %>%
tbl_summary()
I am trying to have the percentage of unknowns listed next to unknown, ideally in parentheses. It would look like 11 (5.5%).
Some have replied with a request for how the missing data appears in my dataset, here is a reprex of that
library(gtsummary)
library(tidyverse)
#> Warning: package 'tibble' was built under R version 4.0.3
#> Warning: package 'readr' was built under R version 4.0.3
library(gtsummary)
df<-
tibble::tribble(
~age, ~sex, ~race, ~weight,
70, "male", "white", 50,
57, "female", "african-american", 87,
64, "male", "white", NA,
46, "male", "white", 49,
87, "male", "hispanic", 51
)
df %>%
select(age,sex,race,weight) %>%
tbl_summary(type = list(age ~ "continuous", weight ~ "continuous"), missing="ifany")