Write a R program to find common elements from multiple vectors.
x = c(10, 20, 30, 20, 20, 25, 29, 26) y = c(10, 50, 30, 20, 20, 35, 19, 56) z = c(10, 40, 30, 20, 20, 25, 49, 26) print("Original Vectors:") print("x: ") print(x) print("y: ") print(y) print("z: ") print(z) print("Common elements from above vectors:") result = intersect(intersect(x,y),z) print(result)
Sample Output:
[1] "Original Vectors:" [1] "x: " [1] 10 20 30 20 20 25 29 26 [1] "y: " [1] 10 50 30 20 20 35 19 56 [1] "z: " [1] 10 40 30 20 20 25 49 26 [1] "Common elements from above vectors:" [1] 10 20 30
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer