I am trying to build a summary table for my homework. The variable I am using to aggregate is a binary variable (0/1).
total <-aggregate(result ~sex, data=x,sum)
However, I want aggregate every few 0s and every few 1s into different groups. For example:
Sex= 1 1 1 1 0 0 1 1
result = 5 1 10 6 7 8 3 2
The table I want to get will be Sex 1 result 22, Sex 0 result 15, sex 1 result 5. How can I do this? Any ideas? Thanks!