Remove duplicate rows in a data frame – Snippet #2
Discover how to remove duplicate rows in a data frame with R
Packages
This snippet requires dplyr.
With the Tidyverse:
library(tidyverse)Without the Tidyverse:
library(dplyr)Code
To remove duplicate rows in a data frame, use distinct(). Duplicate rows are rows that are perfectly identical.
With the pipe operator:
new_df <- df %>%
  distinct()Without the pipe operator:
new_df <- distinct(df)The code above removes all perfectly identical rows in df.

df
new_dfResources

 
            