group_collapse {timeplyr}R Documentation

Key group information

Description

Key group information

Usage

group_collapse(
  data,
  ...,
  order = TRUE,
  sort = FALSE,
  ascending = TRUE,
  .by = NULL,
  .cols = NULL,
  id = TRUE,
  size = TRUE,
  loc = TRUE,
  start = TRUE,
  end = TRUE,
  drop = TRUE
)

Arguments

data

A data frame or vector.

...

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

order

Should the groups be ordered? THE PHYSICAL ORDER OF THE DATA IS NOT CHANGED.
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.

sort

Should the data frame be sorted by the groups?

ascending

Should groups be ordered in ascending order? Default is TRUE and only applies when order = TRUE.

.by

Alternative way of supplying groups using tidyselect notation. This is kept to be consistent with other functions.

.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.

id

Should group IDs be added? Default is TRUE.

size

Should group sizes be added? Default is TRUE.

loc

Should group locations be added? Default is TRUE.

start

Should group start locations be added? Default is TRUE.

end

Should group end locations be added? Default is TRUE.

drop

Should unused factor levels be dropped? Default is TRUE.

Details

group_collapse() is similar to dplyr::group_data() but differs in 3 key regards:

There are 3 ways to specify the groups:

Value

A tibble of unique groups and an integer ID uniquely identifying each group.

Examples

library(timeplyr)
library(dplyr)

iris <- dplyr::as_tibble(iris)
group_collapse(iris) # No groups
group_collapse(iris, Species) # Species groups

iris %>%
  group_by(Species) %>%
  group_collapse() # Same thing

# Group entire data frame
group_collapse(iris, .by = everything())


[Package timeplyr version 0.5.0 Index]