Free Access Week - Data Engineering + BI
Data Engineering and BI courses are free this week!
Free Access Week - Jun 2-8

fastplyr (version 0.5.1)

add_group_id: Add a column of useful IDs (group IDs, row IDs & consecutive IDs)

Description

Add a column of useful IDs (group IDs, row IDs & consecutive IDs)

Usage

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 )

Value

A data frame with the requested ID column.

Arguments

data

A data frame.

...

Additional groups using tidy data-masking rules.
To specify groups using tidyselect, simply use the .by argument.

.order

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.

.ascending

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.

.by

Alternative way of supplying groups using tidyselect notation.

.cols

(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

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.

as_qg

Should the group IDs be returned as a collapse "qG" class? The default (FALSE) always returns an integer vector.

See Also

group_id row_id f_consecutive_id