dplyr (version 0.3.0.2)

distinct: Select distinct/unique rows.

Description

Retain only unique/distinct rows from an input tbl. This is an efficient version of unique. distinct() is best-suited for interactive use, distinct_() for calling from a function.

Usage

distinct(.data, ...)

distinct_(.data, ..., .dots)

Arguments

.data
a tbl
...
Variables to use when determining uniqueness. If there are multiple rows for a given combination of inputs, only the first row will be preserved.
.dots
Used to work around non-standard evaluation. See vignette("nse") for details.

Examples

Run this code
df <- data.frame(
  x = sample(10, 100, rep = TRUE),
  y = sample(10, 100, rep = TRUE)
)
nrow(df)
nrow(distinct(df))
distinct(df, x)
distinct(df, y)

# You can also use distinct on computed variables
distinct(df, diff = abs(x - y))

Run the code above in your browser using DataCamp Workspace