Analogous function for summarise
in dplyr.
summarise_dt(data, ..., by = NULL) summarize_dt(data, ..., by = NULL)
data | data.frame |
---|---|
... | List of variables or name-value pairs of summary/modifications functions. |
by | unquoted name of grouping variable of list of unquoted names of grouping variables. For details see data.table |
data.table
#> avg #> 1: 5.843333#> Species avg #> 1: setosa 5.006 #> 2: versicolor 5.936 #> 3: virginica 6.588#> cyl vs avg #> 1: 6 0 131.6667 #> 2: 4 1 81.8000 #> 3: 6 1 115.2500 #> 4: 8 0 209.2143 #> 5: 4 0 91.0000# the data.table way mtcars %>% summarise_dt(cyl_n = .N, by = .(cyl, vs)) # `.`` is short for list#> cyl vs cyl_n #> 1: 6 0 3 #> 2: 4 1 10 #> 3: 6 1 4 #> 4: 8 0 14 #> 5: 4 0 1