Open jasminacosta opened 11 months ago
Hi Jasmin - can you share the code you have used on steps 1-3?
Sure!
Step 1 code:
Salaries %>% group_by(yearID, teamID) %>% summarize(total_players = n(), team_budget = sum(salary.adj))
Step 2:
teams_and_salaries <- Salaries %>% left_join(Teams)
Step 3:
teams_and_salaries %>% group_by(yearID, teamID) %>% summarize(n = n(), team_budget = sum(salary.adj), cost = team_budget / W) %>% mutate(cost_per_win = cost / 100000)
Hi Jasmin,
It looks like you are maybe making this a little harder than it needs to be in some of the steps.
For Step 1, keep your first line and replace the last 3 with something simliar to this: mutate( salary.adj = salary*(1.03)^( max(yearID) - yearID ) )
So it would like something like this: Salaries <- Salaries %>% mutate( salary.adj = salary*(1.03)^( max(yearID) - yearID ) )
For Step 2, you want to adjust the team salaries based on the above individual adjusted salaries:
teamSalaries <- Salaries %>% group_by( yearID, teamID ) %>% and then this line would be you summarizing team.budget followed by merging Teams, and teamSalaries
Lastly, for Step 3, you will use the mutate function:
So, Teams %>% mutate( cost.per.win = (team.budget / W )/100000 ) %>% here you'll want to arrange based on cost.per.win then, include your table headers here
Hi Professor,
This makes a lot more sense.
Thank you!
Hi Professor,
On step 3 of the lab after using the left_join( ) operator to combine both tables I went on to use the mutate( ) function for the equation. However, how I do get the values to stop repeating itself?
Is it repeating since there is player data where some of the information repeats itself?
Such as the variable W?
Thank you!