concept na_if() in category R
appears as: na_if()

This is an excerpt from Manning's book Exploring Data with R.
The winni_tidy table that we worked hard to make tidy requires yet another change in the name of tidiness. The 9999 value, which is a missing value according to the data creator, needs to be transformed to an NA value. The tidyr package has a useful function for this, and it works nicely in conjunction with dplyr’s mutate: the na_if() function. We can use the same construction as with mutate()/case_when() to modify the temp column, replacing that 9999 value with an NA value (Listing 4.8).
Listing 4.8. Replacement of missing values with the mutate() and na_if() functions.
```{r winni_na_if, paged.print=FALSE} winni_tidy <- winni_tidy %>% mutate(temp = na_if(temp, 9999)) #A ``` # A The na_if() function is used inside of mutate() to modify the temp column. Inside na_if() we first supply the column name to modify, then, we supply the value that is considered to as an NA value.