Retain only unique/distinct rows from an input df.

distinct(.df, ..., .keep_all = FALSE)

Arguments

.df

A data.frame or data.table

...

Columns to select before determining uniqueness. If omitted, will use all columns. tidyselect compatible.

.keep_all

Only relevant if columns are provided to ... arg. This keeps all columns, but only keeps the first row of each distinct values of columns provided to ... arg.

Examples

df <- tidytable(
  x = 1:3,
  y = 4:6,
  z = c("a", "a", "b")
)

df %>%
  distinct()
#> # A tidytable: 3 × 3
#>       x     y z    
#>   <int> <int> <chr>
#> 1     1     4 a    
#> 2     2     5 a    
#> 3     3     6 b    

df %>%
  distinct(z)
#> # A tidytable: 2 × 1
#>   z    
#>   <chr>
#> 1 a    
#> 2 b