Write a R program to create a data frame using two given vectors and display the duplicated elements and unique rows of the said data frame

  • برمجة R

Write a R program to create a data frame using two given vectors and display the duplicated elements and unique rows of the said data frame.

الأجوبة

a = c(10,20,10,10,40,50,20,30)
b = c(10,30,10,20,0,50,30,30)
print("Original data frame:")
ab = data.frame(a,b)
print(ab)
print("Duplicate elements of the said data frame:")
print(duplicated(ab))
print("Unique rows of the said data frame:")
print(unique(ab))

Sample Output:

[1] "Original data frame:"
   a  b
1 10 10
2 20 30
3 10 10
4 10 20
5 40  0
6 50 50
7 20 30
8 30 30
[1] "Duplicate elements of the said data frame:"
[1] FALSE FALSE  TRUE FALSE FALSE FALSE  TRUE FALSE
[1] "Unique rows of the said data frame:"
   a  b
1 10 10
2 20 30
4 10 20
5 40  0
6 50 50
8 30 30
هل كان المحتوى مفيد؟

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

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

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