I have the following data frame
dat <- data.frame(x=c(1,2,3,3,2,1), y=c(3,4,4,5,2,5))
Now I would like to get a third column dividing the y row value by the aggregated y values (based on the unique values in column x). So, then I get row 1 as following: 1,3,0.375; 0.375 has been calculated as 3 / (5+3).
I'm relatively new to R and I hope you can help me. Thank you!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…