Last active
February 20, 2017 07:12
-
-
Save Keiku/f71ea2e61a97c2343fa280ad31f034fe to your computer and use it in GitHub Desktop.
Extract a set from the multiple vectors.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a <- c(1, 3, 5, 7, 9) | |
b <- c(3, 6, 8, 9, 10) | |
c <- c(2, 3, 4, 5, 7, 9) | |
intersect_all <- function(...) Reduce(intersect, list(...)) | |
union_all <- function(...) Reduce(union, list(...)) | |
intersect_all(a, b, c) | |
# [1] 3 9 | |
union_all(a, b, c) | |
# [1] 1 3 5 7 9 6 8 10 2 4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment