if_
conditionsif_none()
, if_any()
and
if_all()
test the elements of the list.
if_none(1:10, is.character, ~ rnorm(10))
#> [1] -0.4366298 0.4270910 1.0192108 -1.5400747 1.6180095 0.1220909
#> [7] 1.2127387 0.3578355 0.7880654 -0.1572356
The defaut for all .p
is isTRUE()
. So you
can:
if_then()
performs a simple “if this then do that”:
if_not()
runs .f
if .p(.x)
is
not TRUE :
And if_else()
is a wrapper around
base::ifelse()
.
If you want these function to return a value, you need to wrap these
values into a mapper / a function. E.g, to return a vector, you’ll need
to write if_then(1, is.numeric, ~ "Yay")
.