Skip to content

Instantly share code, notes, and snippets.

@darokun
Created December 6, 2019 12:49
Show Gist options
  • Save darokun/b13794483fdc77d763d5fc39552ff0bb to your computer and use it in GitHub Desktop.
Save darokun/b13794483fdc77d763d5fc39552ff0bb to your computer and use it in GitHub Desktop.
# from a tweet I found around, by @WeAreRLadies maybe?
x <- 1:4
y <- 3:6
compare <- function(x, y) {
list(
"These values are in x but not in y" = setdiff(x, y),
"These values are in y but not in x" = setdiff(y, x),
"These values are shared between x and y" = intersect(x, y),
"Combined, x and y return these values" = union(x, y)
)
}
compare(x, y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment