Reputation: 423
How can I increase the number of digits on the exponentiated ORs and it corresponding 95% CI from the default 2 to say 3 digits?
library(gtsummary)
data(trial)
glm(response ~ trt, trial, family = binomial) %>%
tbl_regression(exponentiate = TRUE)
res <- glm(response ~ trt, trial, family = binomial) %>%
tbl_regression(exponentiate = TRUE) %>% style_sigfig( digits = 3)
#Error in abs(x) : non-numeric argument to mathematical function
Upvotes: 5
Views: 3612
Reputation: 887118
When the expoentiate
is FALSE
, we can modify the style_sigfig
and if it is TRUE
, change the digits
in style_ratio
as mentioned in the `?tbl_regression
estimate_fun - Function to round and format coefficient estimates. Default is style_sigfig when the coefficients are not transformed, and style_ratio when the coefficients have been exponentiated.
By default, both of them are 2.
library(gtsummary)
library(dplyr)
glm(response ~ trt, trial, family = binomial) %>%
tbl_regression(exponentiate = TRUE,
estimate_fun = purrr::partial(style_ratio, digits = 3),
pvalue_fun = purrr::partial(style_sigfig, digits = 3))
Upvotes: 7