Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

select_helpers

Select helper functions


Description

Set of functions to supplement the tidyselect set of functions for selecting columns of data frames (and other items as well).

  • 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

  • all_stat_cols() selects columns from tbl_summary/tbl_svysummary object with summary statistics (i.e. "stat_0", "stat_1", "stat_2", etc.)

  • all_interaction() selects interaction terms from a regression model

  • all_intercepts() selects intercept terms from a regression model

  • all_contrasts() selects variables in regression model based on their type of contrast

Usage

all_continuous(continuous2 = TRUE)

all_continuous2()

all_categorical(dichotomous = TRUE)

all_dichotomous()

all_tests(tests = NULL)

all_stat_cols(stat_0 = TRUE)

all_interaction()

all_intercepts()

all_contrasts(contrasts_type = NULL)

Arguments

continuous2

Logical indicating whether to include continuous2 variables. Default is TRUE

dichotomous

Logical indicating whether to include dichotomous variables. Default is TRUE

tests

string indicating the test type of the variables to select, e.g. select all variables being compared with "t.test"

stat_0

When FALSE, will not select the "stat_0" column. Default is TRUE

contrasts_type

type of contrast to select. When NULL, all variables with a contrast will be selected. Default is NULL. Select among contrast types c("treatment", "sum", "poly", "helmert", "other")

Value

A character vector of column names selected

Example Output

Example 1

Examples

select_ex1 <-
  trial %>%
  select(age, response, grade) %>%
  tbl_summary(
    statistic = all_continuous() ~ "{mean} ({sd})",
    type = all_dichotomous() ~ "categorical"
  )

gtsummary

Presentation-Ready Data Summary and Analytic Result Tables

v1.4.0
MIT + file LICENSE
Authors
Daniel D. Sjoberg [aut, cre] (<https://orcid.org/0000-0003-0862-2018>), Michael Curry [aut] (<https://orcid.org/0000-0002-0261-4044>), Margie Hannum [aut] (<https://orcid.org/0000-0002-2953-0449>), Joseph Larmarange [aut] (<https://orcid.org/0000-0001-7097-700X>), Karissa Whiting [aut] (<https://orcid.org/0000-0002-4683-1868>), Emily C. Zabor [aut] (<https://orcid.org/0000-0002-1402-4498>), Esther Drill [ctb] (<https://orcid.org/0000-0002-3315-4538>), Jessica Flynn [ctb] (<https://orcid.org/0000-0001-8310-6684>), Jessica Lavery [ctb] (<https://orcid.org/0000-0002-2746-5647>), Stephanie Lobaugh [ctb], Gustavo Zapata Wainberg [ctb] (<https://orcid.org/0000-0002-2524-3637>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.