funique
is a substantially faster alternative to unique
. It is generic with a default vector method and a data frame method.
funique(x, …)# S3 method for default
funique(x, sort = FALSE, method = c("auto", "radix", "hash"), …)
# S3 method for data.frame
funique(x, cols = NULL, sort = FALSE, …)
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, however numeric values are only provided in order of first occurrence when method = "hash"
i.e. the radix method always sorts numeric data.
an integer or character string specifying the method of computation:
Int. | String | Description | ||
1 | "auto" | automatic selection: hash for character, logical or if length(x) < 500 , else radix. |
||
2 | "radix" | use radix ordering to determine unique values. | ||
3 | "hash" | use index hashing to determine unique values. |
compute unique rows according to a subset of columns. Columns can be selected using column names, indices, a logical vector or a selector function (i.e. is.character
). Note: All columns are returned.
arguments passed to radixorderv
, e.g. decreasing
or na.last
. Only applicable in funique.default
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 qF
for some additional computational details.
# 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