How grouping works with the .by argument
mainIn tidytable, you can use the .by argument in functions like summarize(), mutate(), and filter() as a shorthand for the group_by() %>% ... %>% ungroup() workflow. This reduces typing and avoids leaving the data frame in a grouped state.
- Pass a single column:
.by = z - Pass multiple columns:
.by = c(y, z)
df <- data.table(x = c("a", "a", "b"), y = c("a", "a", "b"), z = 1:3)
df %>%
summarize(avg_z = mean(z), .by = c(x, y))