Tsallaka zuwa abun ciki
Justice Tech School

aggregate and by-group Summaries

aggregate summarises a column by groups.

Example
df <- data.frame(c = c("NG", "GH", "NG", "GH"), s = c(90, 70, 80, 60))
print(aggregate(s ~ c, data = df, FUN = mean))
print(tapply(df$s, df$c, max))

Exercise

Group summary.

(s ~ c, df, mean)

Quiz Test

What does ~ mean in aggregate?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.