na_ifs: Set variable to NA when it has specific values

na_ifsR Documentation

Set variable to NA when it has specific values

Description

This function replaces specific values in a variable with NA. It would most commonly be used to remove missing values indicated with codes such as "NA", -999 or "none". (NB: It is very similar to dplyr's na_if but accepts more than one value.)

Usage

na_ifs(x, replace)

Arguments

x

The variable to transform.

replace

One or more values to replace by NA.

Examples

library(dplyr)

ess_health %>% 
    mutate(eisced = na_ifs(eisced, c(7, 55)))

LukasWallrich/timesaveR documentation built on Nov. 29, 2024, 4:47 a.m.