I have a data frame like this:
data=data.frame(ID=c("0001","0002","0003","0004","0004","0004","0001","0001","0002","0003"),Saldo=c(10,10,10,15,20,50,100,80,10,10),place=c("grocery","market","market","cars","market","market","cars","grocery","cars","cars"))
I was trying to calculate total sum of aldo for each individual in ID variable applying cumsum or apply but I don't get the result I want. I would like someone like this:
ID Saldo.Total
1 0001 190
2 0002 20
3 0003 20
4 0004 85