Skip to contents

sort_p() orders the variables of a table by their p-value, smallest first; filter_p() keeps the variables whose p-value is at or below a threshold. A variable's p-value is the smallest p-value among its rows, so the rows of a variable stay together.

Usage

sort_p(x, q = FALSE)

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

Arguments

x

(ltsummary)
A table with a p.value column (or a q.value column when q = TRUE).

q

(scalar logical)
Whether to use the q-value column added by add_q() rather than the p-value column. Default is FALSE.

t

(scalar numeric)
Threshold for filter_p(). Default is 0.05.

Value

The table, with its rows reordered or reduced.

Examples

# Example 1 ----------------------------------
trial |>
  tbl_summary(by = trt, include = c(age, marker, grade, response)) |>
  add_p() |>
  sort_p()
# Example 2 ---------------------------------- glm(response ~ age + grade + trt + marker, trial, family = binomial) |> tbl_regression(exponentiate = TRUE) |> add_global_p() |> filter_p(t = 0.5)