https://github.com/hadley/dplyr
Raw File
Tip revision: 34b4be202e89716c4fa3161cf0b194f31ad6e72c authored by hadley on 23 June 2016, 21:54:59 UTC
Prepare for release
Tip revision: 34b4be2
na_if.Rd
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/na_if.R
\name{na_if}
\alias{na_if}
\title{Convert values to NA.}
\usage{
na_if(x, y)
}
\arguments{
\item{x}{Vector to modify}

\item{y}{If th}
}
\value{
A modified version of \code{x} that replaces any values that
  are equal to \code{y} with NA.
}
\description{
This is a translation of the SQL command \code{NULL_IF}. It is useful
if you want to convert an annoying value to \code{NA}.
}
\examples{
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, "")
}
\seealso{
\code{\link{coalesce}()} to replace missing values with a specified
  value.
}

back to top