Skip to contents

[Deprecated]
This function will soon be removed from broom.helpers. Please consider cards::process_formula_selectors() as an alternative.

Usage

.formula_list_to_named_list(
  x,
  data = NULL,
  var_info = NULL,
  arg_name = NULL,
  select_single = FALSE,
  type_check = NULL,
  type_check_msg = NULL,
  null_allowed = TRUE
)

Arguments

x

list of selecting formulas

data

A data frame to select columns from. Default is NULL

var_info

A data frame of variable names and attributes. May also pass a character vector of variable names. Default is NULL

arg_name

Optional string indicating the source argument name. This helps in the error messaging. Default is NULL.

select_single

Logical indicating whether the result must be a single variable. Default is FALSE

type_check

A predicate function that checks the elements passed on the RHS of the formulas in x= (or the element in a named list) satisfy the function.

type_check_msg

When the type_check= fails, the string provided here will be printed as the error message. When NULL, a generic error message will be printed.

null_allowed

Are NULL values accepted for the right hand side of formulas?

Details

Functions takes a list of formulas, a named list, or a combination of named elements with formula elements and returns a named list. For example, list(age = 1, starts_with("stage") ~ 2).

Shortcuts

A shortcut for specifying an option be applied to all columns/variables is omitting the LHS of the formula. For example, list(~ 1) is equivalent to passing list(everything() ~ 1).

Additionally, a single formula may be passed instead of placing a single formula in a list; e.g. everything() ~ 1 is equivalent to passing list(everything() ~ 1)