I wonder if there is an easy way to get rid of the leading zeros in the regression tables created by gtsummary package in R? I love this package for its functionality but not sure if there is an easy way to format the table to comply with APA guidelines (e.g., no leading zeros for p values)? Thanks!
Use the argument tbl_regression(pvalue_fun=)
to change the way the p-values are rounded and formatted. Example below!
library(gtsummary)
packageVersion("gtsummary")
#> [1] '1.4.1'
# formatting function for p-values that removes leading 0
apa_pvalues <- function(x) {
style_pvalue(x, digits = 2) %>%
stringr::str_replace("0.", ".")
}
tbl <-
lm(marker ~ age + grade, trial) %>%
tbl_regression(pvalue_fun = apa_pvalues)
Created on 2021-07-09 by the reprex package (v2.0.0)