na_if: Convert values to NA.

Description Usage Arguments Value See Also Examples

View source: R/na_if.R

Description

This is a translation of the SQL command NULL_IF. It is useful if you want to convert an annoying value to NA.

Usage

1
na_if(x, y)

Arguments

x

Vector to modify

y

If th

Value

A modified version of x that replaces any values that are equal to y with NA.

See Also

coalesce() to replace missing values with a specified value.

Examples

1
2
3
4
5
6
7
8
na_if(1:5, 5:1)

x <- c(1, -1, 0, 10)
100 / x
100 / na_if(x, 0)

y <- c("abc", "def", "", "ghi")
na_if(y, "")

sctyner/dplyr050 documentation built on May 17, 2019, 2:22 p.m.