| vec_locate_sorted_groups | R Documentation |
vec_locate_sorted_groups() returns a data frame containing a key column
with sorted unique groups, and a loc column with the locations of each
group in x. It is similar to vec_group_loc(), except the groups are
returned sorted rather than by first appearance.
vec_locate_sorted_groups(
x,
...,
direction = "asc",
na_value = "largest",
nan_distinct = FALSE,
chr_proxy_collate = NULL
)
x |
A vector |
... |
These dots are for future extensions and must be empty. |
direction |
Direction to sort in.
|
na_value |
Ordering of missing values.
|
nan_distinct |
A single logical specifying whether or not |
chr_proxy_collate |
A function generating an alternate representation of character vectors to use for collation, often used for locale-aware ordering.
For data frames, Common transformation functions include: |
vec_locate_sorted_groups(x) is equivalent to, but faster than:
info <- vec_group_loc(x) vec_slice(info, vec_order(info$key))
A two column data frame with size equal to vec_size(vec_unique(x)).
A key column of type vec_ptype(x).
A loc column of type list, with elements of type integer.
vec_locate_sorted_groups()vec_proxy_order()
df <- data.frame(
g = sample(2, 10, replace = TRUE),
x = c(NA, sample(5, 9, replace = TRUE))
)
# `vec_locate_sorted_groups()` is similar to `vec_group_loc()`, except keys
# are returned ordered rather than by first appearance.
vec_locate_sorted_groups(df)
vec_group_loc(df)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.