group_by | R Documentation |
Most data operations are done on groups defined by variables.
group_by
will group the data.table by selected variables (setting
them as keys), and arrange them in ascending order.
group_exe
could do computations by group, it receives an object
returned by group_by
.
group_by(.data, ...)
group_exe(.data, ...)
groups(x)
ungroup(x)
.data |
A data.table |
... |
For |
x |
A data.table |
For mutate
and summarise
, it is recommended to
use the innate "by" parameter, which is faster. Once the data.table is
grouped, the order is changed forever.
groups()
could return a character vector of specified groups.
ungroup()
would delete the keys in data.table.
A data.table with keys
a = as.data.table(iris)
a
a %>%
group_by(Species) %>%
group_exe(
head(3)
)
groups(a)
ungroup(a)
groups(a)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.