A simple wrapper around dplyr::recode().

recode_if(x, condition, ...)

Arguments

x

Input vector

condition

Conditions upon which the replacement should occurr

...

Arguments passed on to dplyr::recode

.x

A vector to modify

.default

If supplied, all values not otherwise matched will be given this value. If not supplied and if the replacements are the same type as the original values in .x, unmatched values are not changed. If not supplied and if the replacements are not compatible, unmatched values are replaced with NA..default must be either length 1 or the same length as .x.

.missing

If supplied, any missing values in .x will be replaced by this value. Must be either length 1 or the same length as .x.