I have a data.frame of the following: team_id game_id current_points 1 100 10 1 100 10 1 100 10 2 100 20 2 100 20 2 100 20 3 101 15 3 101 15 3 101 15 4 101 5 4 101 5 4 101 5
We have 2 different games in data frame and 4 separate teams. Eg. Team 1 plays Team 2 in game_id 1. What I need to do is create another 2 column with the points of the other team in the game and the points difference between the two teams. Example team_id game_id current_points other_team_points points_difference 1 100 10 20 -10 1 100 10 20 -10 1 100 10 20 -10 2 100 20 10 10 2 100 20 10 10 2 100 20 10 10 3 101 15 5 10 3 101 15 5 10 3 101 15 5 10 4 101 5 15 -10 4 101 5 15 -10 4 101 5 15 -10 How do I go about this in dplyr? -- Sent from: http://r.789695.n4.nabble.com/datatable-help-f2315188.html _______________________________________________ datatable-help mailing list datatable-help@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help