Skip to contents

Convert Function to Function that is Called if Condition is Met

Usage

toConditional(FUN)

Arguments

FUN

a function

Examples

square <- function(x) x^2
negate <- function(x) -x
`%>%` <- magrittr::`%>%`
do_square <- TRUE
do_negate <- TRUE
10 %>%
  toConditional(square)(do_square) %>%
  toConditional(negate)(do_negate)
#> [1] -100