switch_pipeline: Branch a 'dplyr' pipeline based on a set of conditions

View source: R/utils-dataframe.R

switch_pipelineR Documentation

Branch a dplyr pipeline based on a set of conditions

Description

Branch a dplyr pipeline based on a set of conditions

Usage

switch_pipeline(.x, ...)

Arguments

.x

a dataframe

...

a list of formulae of the type ⁠predicate ~ purrr function⁠ using .x as the single parameter

Value

the result of applying ⁠purrr function⁠ to .x in the case where predicate evaluates to true. Both predicate and function can refer to the pipeline dataframe using .x

Examples


iris %>% switch_pipeline(
  is_col_present(.x, Species) ~ .x %>% dplyr::rename(new = Species)
) %>% dplyr::glimpse()

interfacer documentation built on April 4, 2025, 6:13 a.m.