Hi,
I'm trying to subset unique ReferenceNumbers where Dates and Decstriptions are the same.
I have prepared this simple example
library(dplyr)
My.data <- data.frame(stringsAsFactors=FALSE,
ReferenceNumber = c("xyz", "xyz", "abc", "abc", "abc", "abc", "abc", "abc"),
Date = c("2019-03-22", "2019-03-23", "2017-11-29", "2017-11-29",
"2018-01-11", "2018-01-12", "2018-11-27", "2018-11-27"),
Description = c("bla bla", "bla bla", "aaa", "aaa", "bbb", "bbb", "ccc",
"ccc")
)
My.data
I know how to remove duplicates based on one variable:
My.data.New <- My.data[!duplicated(My.data$ReferenceNumber), ]
My.data.New
...but I would like to remove only records with same RerferenceNumber, same Date and same Description (so as a result I should have 6 records).
Can you help please?