df <- data.frame(
id = c(1, 2, 2, 3, 3, 3, 4),
value = letters[1:7]
)
# Find all duplicates
key_duplicates(df, by = "id")
# Find first occurrence only
key_duplicates(df, by = "id", keep = "first")
Run the code above in your browser using DataLab