Carry out data manipulation within specified groups. Different from
the implementation is split into two operations, namely grouping and implementation.
setkeyv in data.table
to carry out
group_by-like functionalities in dplyr. This is
not only convenient but also efficient in computation.
group_by_dt(.data, ..., cols = NULL) group_exe_dt(.data, ...)
A data frame
Variables to group by for
A character vector of column names to group by.
group_exe_dt are a pair of functions
to be used in combination. It utilizes the feature of key setting in data.table,
which provides high performance for group operations, especially when you have
to operate by specific groups frequently.
A data.table with keys
# aggregation after grouping using group_exe_dt as.data.table(iris) -> a a %>% group_by_dt(Species) %>% group_exe_dt(head(1)) a %>% group_by_dt(Species) %>% group_exe_dt( head(3) %>% summarise_dt(sum = sum(Sepal.Length)) ) mtcars %>% group_by_dt("cyl|am") %>% group_exe_dt( summarise_dt(mpg_sum = sum(mpg)) ) # equals to mtcars %>% group_by_dt(cols = c("cyl","am")) %>% group_exe_dt( summarise_dt(mpg_sum = sum(mpg)) )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.