I want to count the number of occurrences of a factor in a data frame. For example, to count the number of events of a given type in the code below:
library(plyr
Quite similar to @DWin's answer:
> aggregate(quantity~type, events, FUN=sum) type quantity 1 A 3 2 B 1 3 C 0