Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement na_if #1707

Closed
hadley opened this issue Mar 11, 2016 · 1 comment
Closed

Implement na_if #1707

hadley opened this issue Mar 11, 2016 · 1 comment
Labels
feature a feature request or enhancement
Milestone

Comments

@hadley
Copy link
Member

hadley commented Mar 11, 2016

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
}
@hadley hadley added this to the 0.5 milestone Mar 11, 2016
@hadley hadley added feature a feature request or enhancement data frame labels Mar 11, 2016
@hadley
Copy link
Member Author

hadley commented Mar 11, 2016

Also need to add SQL translation.

@hadley hadley closed this as completed in fe35a11 Mar 14, 2016
@lock lock bot locked as resolved and limited conversation to collaborators Jun 9, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

1 participant