Skip to content

Implement na_if #1707

@hadley

Description

@hadley

Equivalent of SQL NULL_IF, http://www.resolvinghere.com/sof/6220956.shtml

na_if <- function(x, y) {
  if (length(y) != length(x) && length(y) != 1) {
   stop("`y` must be length 1 or same length as x")
  }

  x[x == y] <- NA
  x
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions