| unique_ | R Documentation |
unique functionunique_() is a usually faster alternative to unique() with optional
sorting included. The internal API of this function is designed to be
simple and generic to allow for working with all kinds of objects that can
be reduced to a unique set.
Internally unique_() calculates unique group IDs for the given vector
in the range [1, n] where 1 denotes the first group and n denotes
the nth group.
This function will work correctly as long as there
is a correctly implemented collapse::GRP method and a [ method
for the object.
In the future cheapr will include a group_id S3 generic to replace the use
of collapse::GRP here, of which is arguably more difficult to write correct
methods for.
unique_(x, sort = FALSE)
x |
A vector (or data frame). |
sort |
Should unique result be sorted? Default is |
A unique vector (or data frame).
library(cheapr)
x <- rep_(3:1, 3)
unique_(x)
unique_(x, sort = TRUE)
# Unique rows
iris |>
sset(j = c("Petal.Width", "Species")) |>
unique_()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.