Q:

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

0

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.

All Answers

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

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

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