x <- c(1, 2, 2, 3, 3, 3, 4)
Fx <- c(.4, .2, .4, .5, .2, 1.2, .8)
So I want to group Fx by values of x and then sum the values in the groups.
It should return:
new_x <- c(1, 2, 3, 4)
new_Fx <- c(.4, .2+.4, .5+.2+1.2, .8)
How can I do this in r?