funique
is a substantially faster alternative to unique
. It is generic with a default vector and a data frame methods.
funique(x, …)# S3 method for default
funique(x, sort = FALSE, method = "auto", …)
# S3 method for data.frame
funique(x, cols = NULL, sort = FALSE, method = "auto", …)
# S3 method for sf
funique(x, cols = NULL, sort = FALSE, method = "auto", …)
a atomic vector or data frame / list of equal-length columns.
logical. TRUE
orders the unique elements / rows. FALSE
returns unique values in order of first occurrence.
an integer or character string specifying the method of computation:
Int. | String | Description | ||
1 | "auto" | automatic selection: hash if sort = FALSE else radix. |
||
2 | "radix" | use radix ordering to determine unique values. Supports sort = FALSE but only for character data. |
||
3 | "hash" | use index hashing to determine unique values. Supports sort = TRUE but only for atomic vectors (default method). |
compute unique rows according to a subset of columns. Columns can be selected using column names, indices, a logical vector or a selector function (e.g. is.character
). Note: All columns are returned.
arguments passed to radixorderv
, e.g. decreasing
or na.last
. Only applicable if method = "radix"
.
x
with duplicate elements/rows removed.
If x
is a data frame / list and all rows are already unique, then x
is returned. Otherwise a copy of x
with duplicate rows removed is returned. See group
for some additional computational details.
The sf method simply ignores the geometry column when determining unique values.
# NOT RUN {
funique(mtcars$cyl)
funique(gv(mtcars, c(2,8,9)))
funique(mtcars, cols = c(2,8,9))
# }
Run the code above in your browser using DataLab