Skip to content

Instantly share code, notes, and snippets.

@sharlagelfand
Created June 21, 2019 02:45
Show Gist options
  • Save sharlagelfand/20f96f3598fd6b8f4117bce675ad8db0 to your computer and use it in GitHub Desktop.
Save sharlagelfand/20f96f3598fd6b8f4117bce675ad8db0 to your computer and use it in GitHub Desktop.
not_equal <- function(a, b){
ifelse(a != b | is.na(a) | is.na(b),
ifelse(is.na(a) & is.na(b),
NA,
TRUE),
FALSE)
}
not_equal("A", "A")
#> [1] FALSE
not_equal("A", NA)
#> [1] TRUE
not_equal(NA, "A")
#> [1] TRUE
not_equal(NA, NA)
#> [1] NA
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment