Hi RStudio Community, I would like to list duplicate ids by two columns (id and date1) below if somebody can help me. It is highly appreciate it. Thanks
r
# identify duplicates by two columns
data <- data.frame(id = c(1L,2L,2L,3L,3L,4L,5L,6L,6L,7L),
date1 = c("2020-01-25", "2021-03-15","2021-03-15","2021-05-11","2021-05-11","2020-06-07","2021-08-08", "2020-10-18","2020-10-18", "2021-11-11"),
x = factor(c("B", "B", "A", "F", "A", "B", "A", "B","A", "B")),
stringsAsFactors = FALSE)
#duplicates
data$id[duplicated(data$id)]
sum(duplicated(data[,1:2]))