
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)
A data.table
For group_by
:Variables to group by.
For group_exe
:Any data manipulation arguments that
could be implemented on a data.table.
A data.table
A data.table with keys
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.
# NOT RUN {
a = as.data.table(iris)
a
a %>%
group_by(Species) %>%
group_exe(
head(3)
)
groups(a)
ungroup(a)
groups(a)
# }
Run the code above in your browser using DataLab