If this, then that
if_then(.x, .p = isTRUE, .f)if_not(.x, .p = isTRUE, .f)if_else(.x, .p = isTRUE, .f, .else)
if_not(.x, .p = isTRUE, .f)
if_else(.x, .p = isTRUE, .f, .else)
the object to test. If NULL (the default), only .p is evaluated.
NULL
the predicate for testing. Defaut is isTRUE.
isTRUE
a mapper or a function run if .p(.x) is TRUE
a mapper or a function run if .p(.x) is not TRUE
Depending on wether or not .p(.x) is TRUE, .f() or .else() is run.
# NOT RUN { a <- if_then(1, is.numeric, ~ "Yay") a <- if_not(1, is.character, ~ "Yay") a <- if_else(.x = TRUE, .f = ~ "Yay", .else = ~ "Nay") # }
Run the code above in your browser using DataLab