df <- data.table(
a = 1:3,
b = 4:6,
c = c("a", "a", "b"),
d = c("a", "a", "b")
)
df %>%
summarize.(avg_a = mean(a),
max_b = max(b),
.by = c)
df %>%
summarize.(avg_a = mean(a),
.by = c(c, d))
Run the code above in your browser using DataLab