switch_pipeline {interfacer}R 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()

[Package interfacer version 0.2.3 Index]