How can I create a column that cumulatively adds the sum of two previous rows based on conditions?
I tried asking this question before but was it was poorly stated. This is a new attempt cause I haven't solved it yet. I have a dataset with winners, losers, date, winner_points and loser_points. For each row, I want two new columns, one for the winner and one for the loser that shows how many points they have scored so far (as both winners and losers). Example data: winner <- c(1,2,3,1,2,3,1,2,3) loser <- c(3,1,1,2,1,1,3,1,2) date <- c("2017-10-01","2017-10-02","2017-10-03","2017-10-04","2017-10-05","2017-10-06","2017-10-07","2017-10-08","2017-10-09") winner_points <- c(2,1,2,1,2,1,2,1,2)