Replace values satisfying a predicate
Arguments
- x
A vector.
- f
A function, called with
x
. The return value is used to select elements inx
to replace withvalues
.- values
Values assigned to elements of
x
satisfyingf
.
See also
replace()
which this thinly wraps.
Examples
replace_if(c(1, NA, 3), is.na, 42)
#> [1] 1 42 3