"I'm working on a data set and would like to extract all non-repeating records into a new data-set. My current data-set have both duplicate and non-duplicate records. Is there any way to get only the unique records?
I have tried the below code which gave me all duplicate records.
unique <- Data[!duplicated(Data),]
NewData <- unique[unique$x %in% unique$x[duplicated(unique$x)],]
For example I have taken the below data-set
x <- c("A","B","B","D","A","C","B","A")
y <- c(1,2,3,4,5,6,7,8)
z <- c(8,7,6,5,4,3,2,1)
Data <- data.frame(x,y,z)
Dataframe:
x y z
A 1 8
B 2 7
B 3 6
D 4 5
A 5 4
C 6 3
B 7 2
A 8 1
What I want is:
x y z
D 4 5
C 6 3