Right now I have a data frame from games day (titled: games_day) that looks like this
I'd like to create a new variable in the data frame summing the total points for and against each team so it will look like this
so far I have used this code in dplyr
games_day %>% group_by(team_id) %>% summarize(total_points_for = sum(points_for))
this does not add it into the data frame as a new variable though. Any help with this would be greatly appreciated