Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

distinct

Select distinct/unique rows in data.table


Description

Analogous function for distinct in dplyr

Usage

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

Arguments

.data

data.table

...

Optional variables to use when determining uniqueness. If there are multiple rows for a given combination of inputs, only the first row will be preserved. If omitted, will use all variables.

.keep_all

If TRUE, keep all variables in data.table. If a combination of ... is not distinct, this keeps the first row of values.

Value

data.table

See Also

Examples

a = as.data.table(iris)
 b = as.data.table(mtcars)
 a %>% distinct(Species)
 b %>% distinct(cyl,vs,.keep_all = TRUE)

tidyft

Tidy Verbs for Fast Data Operations by Reference

v0.4.5
MIT + file LICENSE
Authors
Tian-Yuan Huang [aut, cre] (<https://orcid.org/0000-0002-3591-4203>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.