#2 – Remove duplicate rows in a data frame

R packages:

Required packages

To run the snippet, you need to load dplyr.

If you use the Tidyverse:

library(tidyverse)
Code language: R (r)

If you do not use the Tidyverse:

library(dplyr)
Code language: R (r)

Snippet

To remove duplicate rows in a data frame, use distinct(). Duplicates are rows that are replicated at least twice.

If you use the pipe operator:

df <- df %>%
    distinct()
Code language: R (r)

If you do not use the pipe operator:

df <- distinct(df)
Code language: R (r)

Documentation