nest_by.: Nest data.tables

Description Usage Arguments Examples

View source: R/nest_by.R

Description

Nest data.tables by group

Usage

1
nest_by.(.df, ..., .key = "data", .keep = FALSE)

Arguments

.df

A data.frame or data.table

...

Columns to group by. If empty nests the entire data.table. tidyselect compatible.

.key

Name of the new column created by nesting.

.keep

Should the grouping columns be kept in the list column.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
test_df <- data.table(
  a = 1:5,
  b = 6:10,
  c = c(rep("a", 3), rep("b", 2)),
  d = c(rep("a", 3), rep("b", 2))
)

test_df %>%
  nest_by.()

test_df %>%
  nest_by.(c, d)

test_df %>%
  nest_by.(where(is.character))

test_df %>%
  nest_by.(c, d, .keep = TRUE)

mtfairbanks/gdt documentation built on May 4, 2021, 9:44 a.m.