Description Usage Arguments Value Examples
Analogous function for group_by
in dplyr,
but in another efficient way.
1 |
data |
data.frame |
by |
Variables to group by,unquoted name of grouping variable of list of unquoted names of grouping variables. |
... |
Any data manipulation arguments that could be implemented on a data.frame. |
data.table
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | iris %>% group_dt(by = Species,slice_dt(1:2))
iris %>% group_dt(Species,filter_dt(Sepal.Length == max(Sepal.Length)))
iris %>% group_dt(Species,summarise_dt(new = max(Sepal.Length)))
# you can pipe in the `group_dt`
iris %>% group_dt(Species,
mutate_dt(max= max(Sepal.Length)) %>%
summarise_dt(sum=sum(Sepal.Length)))
# for summarise_dt, you can use "by" to calculate within the group
mtcars %>%
summarise_dt(
disp = mean(disp),
hp = mean(hp),
by = cyl
)
# but you could also, of course, use group_dt
mtcars %>%
group_dt(by =.(vs,am),
summarise_dt(avg = mean(mpg)))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.