Q:

Write a R program to find the elements of a given vector that are not in another given vector

0

Write a R program to find the elements of a given vector that are not in another given vector.

All Answers

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

a = c(0, 10, 10, 10, 20, 30, 40, 40, 40, 50, 60)
b = c(10, 10, 20, 30, 40, 40, 50)
print("Original vector-1:")
print(a)
print("Original vector-2:")
print(b)
print("Elements of a that are not in b:")
result = setdiff(a, b)
print(result)

Sample Output:

[1] "Original vector-1:"
 [1]  0 10 10 10 20 30 40 40 40 50 60
[1] "Original vector-2:"
[1] 10 10 20 30 40 40 50
[1] "Elements of a that are not in b:"
[1]  0 60

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