I have two columns. One that has several duplicate values (col A) (like 10, 10, 20, 5, 10, 20, etc...). The other (col B) is a binary (0/1) variable. I need to get R to first sort the first column A, if necessary, and then look at all the duplicate values, and their corresponding values in the second column, B. Then, for each set of duplicate values in col A, I need to sum the values in col B. So, if there are 5 10s in col A, then I need to sum the 1s in col B associated with each of these 5 10s.
How do I do this?
Thanks.