user3108800
user3108800

Reputation: 75

How do I display 3 significant digits for p values in logistic regression table using add_global_p (car, gtsummary)

Where/how do I insert style_p_value argument to display 3 significant digits for the p values in this table?

if (requireNamespace("car")) {
  tbl_uv_global_ex2 <-
    trial[c("response", "trt", "age", "grade")] %>%
    tbl_uvregression(
      method = glm,
      y = response,
      method.args = list(family = binomial),
      exponentiate = TRUE
    ) %>%
    add_global_p()
}

Upvotes: 1

Views: 1823

Answers (1)

Daniel D. Sjoberg
Daniel D. Sjoberg

Reputation: 11679

Example below with 3 sigfigs for the p-value :)

library(gtsummary)
packageVersion("gtsummary")
#> [1] '1.4.2'
tbl <-
  trial[c("response", "trt", "age", "grade")] %>%
  tbl_uvregression(
    method = glm,
    y = response,
    method.args = list(family = binomial),
    exponentiate = TRUE,
    pvalue_fun = ~style_sigfig(., digits = 3) # style p-values with 3 sig figs
  ) %>%
  add_global_p()
#> add_global_p: Global p-values for variable(s) `add_global_p(include = c("trt",
#> "age", "grade"))` were calculated with
#>   `car::Anova(mod = x$model_obj, type = "III")`

enter image description here Created on 2021-09-14 by the reprex package (v2.0.1)

Upvotes: 1

Related Questions