Learn R Programming

tidytable (version 0.6.2)

cur_group_id.: Current group context

Description

These functions give information about the "current" group.

  • cur_group_id.() gives a group identification number

  • cur_group_rows.() gives the row indices for each group

Can be used inside summarize.(), mutate.(), & filter.()

Usage

cur_group_id.()

cur_group_rows.()

Arguments

Examples

Run this code
# NOT RUN {
test_df <- data.table(
  x = 1:5,
  y = c("a", "a", "a", "b", "b")
)

test_df %>%
  mutate.(group_id = cur_group_id.(),
          .by = y)

test_df %>%
  mutate.(group_rows = cur_group_rows.(),
          .by = y)
# }

Run the code above in your browser using DataLab