indicate_duplicates(c(1, 2, NA, NA, 1))
indicate_duplicates(c(1, 2, 3, 4, 4))
# Useful to check duplicates in data frames.
df <- data.frame(
id = c(1, 2, 1, 2, 3), year = c(2010, 2011, 2010, 2010, 2011),
value = c(1, 2, 3, 4, 5)
)
df[indicate_duplicates(df[, c("id", "year")]), ]
Run the code above in your browser using DataLab