我正在使用下面的 R 代码,但无法弄清楚如何获得具有两位小数的置信区间:
library(gtsummary)
survey::svydesign(id = ~PSU, weights = ~WT_analysis, strata = ~Stratum, data = nyts23_drop_na)|>
tbl_svysummary(digits = list(all_categorical() ~ c(0, 2)), by = ADDI_cat1, percent = "column",
include = c(SCHOOLTYPE,race_cat,SEX,sex_ori)) |>
add_stat_label() |>
add_ci(pattern = "{stat} (95% CI {ci})") |>
add_p()
我尝试了上面的代码,但无法获得小数点后两位的置信区间。我能够获得统计数据的两位小数,但这些统计数据的置信区间却不相同(即两位小数)。
style_fun
参数是否允许您进行所需的更改? 谢谢!
library(srvyr)
library(gtsummary)
data(api, package = "survey")
apistrat %>%
as_survey_design(strata = stype, weights = pw) %>%
tbl_svysummary(digits = list(all_categorical() ~ c(0, 2)), by = awards, percent = "column",
include = c(both,stype)) |>
add_stat_label() |>
add_ci(
pattern = "{stat} (95% CI {ci})",
style_fun =
list(
all_continuous() ~ label_style_sigfig(),
all_categorical() ~ label_style_sigfig(scale = 100,digits=4)
)
) |>
add_p()