In this tutorial, we will learn how to remove duplicate rows in R Dataframe.

To remove duplicate rows in R dataframe, use unique() function with the following syntax

where

  • redundantDataFrame is the dataframe with duplicate rows.
  • newDataFrame is the dataframe with all the duplicate rows removed.
  • unique is the keyword.

Example – Remove Duplicate Rows in R Dataframe

In this example, we will create a dataframe with a duplicate row of another. We shall use unique function to remove these duplicate rows.

Row 1 and Row 4 are duplicates. When we run uniqe() function, it retains the first row which is original and any duplicates further in the dataframe are removed.