Description Usage Arguments Examples
Retain only unique/distinct rows from an input tbl. This is similar
to unique.data.frame
, but considerably faster.
1 2 3 |
.data |
a tbl |
... |
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 |
.dots |
Used to work around non-standard evaluation. See
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | df <- data.frame(
x = sample(10, 100, rep = TRUE),
y = sample(10, 100, rep = TRUE)
)
nrow(df)
nrow(distinct(df))
nrow(distinct(df, x, y))
distinct(df, x)
distinct(df, y)
# Can choose to keep all other variables as well
distinct(df, x, .keep_all = TRUE)
distinct(df, y, .keep_all = TRUE)
# You can also use distinct on computed variables
distinct(df, diff = abs(x - y))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.