我有一个包含很大一部分未知数的连续变量。我的顾问要求我将百分比放在旁边的列中。这个代表模仿了我正在尝试做的事情。
library(tidyverse)
library(gtsummary)
trial %>% # included with gtsummary package
select(trt, age, grade) %>%
tbl_summary()
我试图将未知数的百分比列在未知数旁边,最好放在括号中。它看起来像 11 (5.5%)。
有些人回复了关于丢失数据如何出现在我的数据集中的请求,这是一个代表
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")