Add a column of useful IDs (group IDs, row IDs & consecutive IDs)
add_group_id(data, ...)# S3 method for data.frame
add_group_id(
data,
...,
.order = df_group_by_order_default(data),
.ascending = TRUE,
.by = NULL,
.cols = NULL,
.name = NULL,
as_qg = FALSE
)
add_row_id(data, ...)
# S3 method for data.frame
add_row_id(
data,
...,
.ascending = TRUE,
.by = NULL,
.cols = NULL,
.name = NULL
)
add_consecutive_id(data, ...)
# S3 method for data.frame
add_consecutive_id(
data,
...,
.order = df_group_by_order_default(data),
.by = NULL,
.cols = NULL,
.name = NULL
)
A data frame with the requested ID column.
A data frame.
Additional groups using tidy data-masking
rules.
To specify groups using tidyselect
, simply use the .by
argument.
Should the groups be ordered?
When .order
is TRUE
(the default) the group IDs will be
ordered but not sorted.
If FALSE
the order of the group IDs will be based on first appearance.
Should the order be ascending or descending?
The default is TRUE
.
For add_row_id()
this determines if the
row IDs are in increasing or decreasing order.
NOTE - When order = FALSE
, the ascending
argument is
ignored. This is something that will be fixed in a later version.
Alternative way of supplying groups using tidyselect
notation.
(Optional) alternative to ...
that accepts
a named character vector or numeric vector.
If speed is an expensive resource, it is recommended to use this.
Name of the added ID column which should be a
character vector of length 1.
If .name = NULL
(the default),
add_group_id()
will add a column named "group_id",
and if one already exists, a unique name will be used.
Should the group IDs be returned as a
collapse "qG" class? The default (FALSE
) always returns
an integer vector.
group_id row_id f_consecutive_id