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

  • برمجة R

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

الأجوبة

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
هل كان المحتوى مفيد؟

معلومات ذات صلة

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...