Skip to contents

Selectors that supplement the tidyselect-style selection language for choosing variables of a summary table (and columns of its body).

  • all_continuous() selects continuous variables

  • all_continuous2() selects only type "continuous2"

  • all_categorical() selects categorical (including "dichotomous") variables

  • all_dichotomous() selects only type "dichotomous"

  • all_tests() selects variables by the name of the test performed in add_p()

  • all_stat_cols() selects the columns of a tbl_summary table that hold summary statistics ("stat_0", "stat_1", "stat_2", ...)

  • all_interaction() selects the interaction terms of a regression table

  • all_intercepts() selects the intercept of a regression table

  • all_contrasts() selects the categorical variables of a regression table by the type of contrast they were coded with

They are resolved against the table's variables, so they only work inside ltsummary functions. Alongside them, the common tidyselect forms are accepted: bare names, strings, c(), - for exclusion, ranges such as age:grade, and the helpers everything(), all_of(), any_of(), starts_with(), ends_with(), contains(), matches(), where() and last_col(). See syntax for details.

Usage

all_continuous(continuous2 = TRUE)

all_continuous2()

all_categorical(dichotomous = TRUE)

all_dichotomous()

all_stat_cols(stat_0 = TRUE)

all_tests(tests)

all_interaction()

all_intercepts()

all_contrasts(
  contrasts_type = c("treatment", "sum", "poly", "helmert", "sdif", "other")
)

Arguments

continuous2

(scalar logical)
Whether all_continuous() also selects "continuous2" variables. Default is TRUE.

dichotomous

(scalar logical)
Whether all_categorical() also selects dichotomous variables. Default is TRUE.

stat_0

(scalar logical)
Whether all_stat_cols() selects the overall column "stat_0". Default is TRUE.

tests

(character)
Names of tests, e.g. "t.test"; selects the variables compared with one of those tests in add_p().

contrasts_type

(character)
One or more of "treatment", "sum", "poly", "helmert", "sdif" and "other". Default selects every type.

Value

A selector object, resolved to column names by the function it is passed to.

See also

Formula-list and selector syntax, used throughout the package.

Other selectors: syntax

Examples

# Example 1 ----------------------------------
# statistics by summary type
trial |>
  tbl_summary(
    include = c(age, marker, grade, response),
    statistic = list(
      all_continuous() ~ "{mean} ({sd})",
      all_categorical(dichotomous = FALSE) ~ "{n} / {N}",
      all_dichotomous() ~ "{p}%"
    )
  )
# Example 2 ---------------------------------- # `all_stat_cols()` selects the statistic columns of a table trial |> tbl_summary(by = trt, include = c(age, grade)) |> add_overall() |> modify_header(all_stat_cols(stat_0 = FALSE) ~ "**{level}**") |> modify_spanning_header(all_stat_cols(stat_0 = FALSE) ~ "**Treatment**")
# Example 3 ---------------------------------- # `all_tests()` passes arguments to every variable compared with a test trial |> tbl_summary(by = trt, include = c(age, marker, grade)) |> add_p( test = all_continuous() ~ "t.test", test.args = all_tests("t.test") ~ list(var.equal = TRUE) )