na_if_value()
converts a value to NA. The same asdplyr::na_if()
.value_if_na()
converts NA to a value. The same astidyr::replace_na()
.
Examples
x <- c(1, 2, NA, 4)
na_if_value(x, 2)
#> [1] 1 NA NA 4
value_if_na(x, 3)
#> [1] 1 2 3 4
na_if_value()
converts a value to NA. The same as dplyr::na_if()
.
value_if_na()
converts NA to a value. The same as tidyr::replace_na()
.
x <- c(1, 2, NA, 4)
na_if_value(x, 2)
#> [1] 1 NA NA 4
value_if_na(x, 3)
#> [1] 1 2 3 4