我正在使用 gtsummary 包通过 tbl_summary 函数制作一些表格。特别是,我有一个显示值(平均值±标准差)类似于 1,234,000 +- 567,890。有没有办法显示 1.234e+6 +- 5.678e+5 这样的值?
我找到了 label_style_number 函数,但我不知道如何使用它。
谢谢
您可以在
tbl_summary(digits)
参数中指定您想要使用的任何函数。
library(gtsummary)
sci_fmt <- \(x) format(x, digits = 3, scientific = TRUE)
sci_fmt(1234324234)
#> [1] "1.23e+09"
trial |>
tbl_summary(
include = age,
statistic = age ~ "{mean} ({sd})",
digits = age ~ sci_fmt
) |>
as_kable()
特点 | N = 200 |
---|---|
年龄 | 4.72e+01(1.43e+01) |
未知 | 11 |
创建于 2024 年 10 月 2 日,使用 reprex v2.1.1