Learn R Programming

interfacer (version 0.3.3)

switch_pipeline: 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, ...)

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

Arguments

.x

a dataframe

...

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

Examples

Run this code

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

Run the code above in your browser using DataLab