nest_by | R Documentation |
Nest data.tables by group.
Note: nest_by()
does not return a rowwise tidytable.
nest_by(.df, ..., .key = "data", .keep = FALSE)
.df |
A data.frame or data.table |
... |
Columns to group by. If empty nests the entire data.table.
|
.key |
Name of the new column created by nesting. |
.keep |
Should the grouping columns be kept in the list column. |
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))
)
df %>%
nest_by()
df %>%
nest_by(c, d)
df %>%
nest_by(where(is.character))
df %>%
nest_by(c, d, .keep = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.