context {tidytable}R Documentation

Context functions

Description

These functions give information about the "current" group.

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

Usage

cur_column()

cur_data()

cur_group_id()

cur_group_rows()

Examples

df <- data.table(
  x = 1:5,
  y = c("a", "a", "a", "b", "b")
)

df %>%
  mutate(
    across(c(x, y), ~ paste(cur_column(), .x))
  )

df %>%
  summarize(data = list(cur_data()),
            .by = y)

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

df %>%
  mutate(group_rows = cur_group_rows(),
         .by = y)

[Package tidytable version 0.11.1 Index]