Skip to contents

Sort/filter by p-values

Usage

sort_p(x, q = FALSE)

filter_p(x, q = FALSE, t = 0.05)

Arguments

x

(gtsummary)
An object created using gtsummary functions

q

(scalar logical)
When TRUE will check the q-value column rather than the p-value. Default is FALSE.

t

(scalar numeric)
Threshold below which values will be retained. Default is 0.05.

Author

Karissa Whiting, Daniel D. Sjoberg

Examples

# Example 1 ----------------------------------
trial %>%
  select(age, grade, response, trt) %>%
  tbl_summary(by = trt) %>%
  add_p() %>%
  filter_p(t = 0.8) %>%
  sort_p()
Characteristic Drug A
N = 98
1
Drug B
N = 102
1
p-value2
Tumor Response 28 (29%) 33 (34%) 0.5
    Unknown 3 4
Age 46 (37, 60) 48 (39, 56) 0.7
    Unknown 7 4
1 Median (Q1, Q3); n (%)
2 Wilcoxon rank sum test; Pearson’s Chi-squared test
# Example 2 ---------------------------------- glm(response ~ trt + grade, trial, family = binomial(link = "logit")) %>% tbl_regression(exponentiate = TRUE) %>% sort_p()
Characteristic OR1 95% CI1 p-value
Chemotherapy Treatment


    Drug A
    Drug B 1.21 0.66, 2.24 0.5
Grade


    I
    II 0.94 0.44, 1.98 0.9
    III 1.09 0.52, 2.27 0.8
1 OR = Odds Ratio, CI = Confidence Interval