Q:

Write a R program to find common elements from multiple vectors

0

Write a R program to find common elements from multiple vectors.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now