Duplicates
Last updated: January 18, 2021
# Show duplicates
df %>%
filter(duplicated(.$column_name))
# Show both the original and duplicate rows
dupes <- df %>%
filter(duplicated(.$column_name))
df %>%
filter(column_name %in% dupes$column_name) %>%
arrange(column_name)
# Delete duplicates
df <- df %>% distinct(column_name, .keep_all = TRUE)
âšī¸ This page is part of my knowledge base for R, the popular statistical programming language. I attempt to use idiomatic practices with the tidyverse
collection of packages as much as possible. If you have suggestions for ways to improve this code, please contact me or use the survey link below..