Slip8
Write an R program to create a data frame using two given vectors and
display the duplicated elements and unique rows of the said data frame.
x = c(10,20,10,10,40,50,20,30)
y = c(10,30,10,20,0,50,30,30)
print("Original data frame:")
c = data.frame(x,y)
print(c)
print("Duplicate elements of the said data frame:")
print(duplicated(c))
print("Unique rows of the said data frame:")
print(unique(c))
Output
> a = c(10,20,10,10,40,50,20,30)
> b = c(10,30,10,20,0,50,30,30)
> print("Original data frame:")
[1] "Original data frame:"
> ab = data.frame(a,b)
> print(ab)
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
> print("Duplicate elements of the said data frame:")
[1] "Duplicate elements of the said data frame:"
> print(duplicated(ab))
[1] FALSE FALSE TRUE FALSE FALSE
FALSE TRUE FALSE
> print("Unique rows of the said data frame:")
[1] "Unique rows of the said data frame:"
> print(unique(ab))
a b
1 10 10
2 20 30
4 10 20
5 40 0
6 50 50
8 30 30