to summarize my problem i got a dataframe like:
1 10
3 20
5 40
6 30
1 100
2 25
7 13
3 70
Like for an ID in the 1st and a price in the 2nd column. I need an output like:
1 110
3 90
5 40
6 30
1 110
2 25
7 13
3 90
So the sum of all prices with same ID without any loops, without rearranging or compressing. I don't want solutions like:
1 110
2 25
3 90
5 40
6 30
7 13
And this one is also not helpful:
for(i in 1:8){
x=0
for(j in 1:8){
if(df[i,1]==df[j,1]){x=x+df[j,2]}}
df[i,3]=x
}
df[,2]=df[,3]
cause it only works for small dataframes (df).
I guess the solution is simple... but anyhow I could not make it..
Thank you in advance :)