My data has 65 columns, but I want to sort data frame based on team_id and then I need to calculate the number of consecutive wins or losses from the team_outcome column based upon team_id.
Example, a team with 3 wins in a row would show 1,2,3 down the column. If the team then went on a 3 game losing streak, the next 3 rows would be -1,-2,-3 etc. How can I do this? This my data:
>team_id<-c("Minnesota", "Dallas", "Minnesota", "Chicago", "Brooklyn", "Cleveland", "Washington","Minnesota", "Dallas")
>team_outcome<-c("win","loss","loss","win","win","loss","win","loss","win")