I have a data set that looks like this. You can see that column X2 has key values. I would like to sum the pair values from column X1 by the key values in column X2. I have been trying to use ddply or aggregate but I am running into problems. Does anyone have a simple way to do this?
> X1=rnorm(30,mean=20, sd=10)
> X2=rep(1:15,2)
>df= data.frame(X1,X2)
          X1 X2
1  10.065545  1
2   6.938315  2
3   5.657782  3
4  11.371521  4
5  37.037992  5
6  13.443674  6
7   8.868314  7
8   5.944946  8
9  18.493563  9
10 16.059931 10
11 22.520693 11
12 17.172936 12
13 28.676676 13
14 27.200911 14
15 30.560696 15
16 22.435021  1
17 31.143627  2
18 19.234473  3
19 29.329251  4
20 18.420183  5
21 13.184905  6
22  7.798989  7
23 12.910870  8
24 12.513204  9
25 25.760775 10
26 19.479005 11
27 13.696628 12
28 11.016639 13
29 35.126859 14
30 17.632507 15
 
     
     
    