Payroll

Use the MLB_teams data in the mdsr package to create an informative data graphic that illustrates the relationship between winning percentage and payroll in context.

SOLUTION:

data("MLB_teams", package= 'mdsr')

MLB_teamsGr=
  MLB_teams %>%
    mutate(MLB_teamsPop= cut(metroPop,
                            breaks= c(0,2500000,5000000,10000000,25000000),
                            labels= c("low", "medium", "high", "very high")))
  
MLB_teamsGr %>%
  ggplot(aes(x= payroll ,y= WPct)) +
    geom_point(aes(color= MLB_teamsPop))+
    geom_smooth(method= "lm", se=FALSE, aes(color= MLB_teamsPop))+
    labs(x="Payroll per team", y="Winning Percentage")
Relationship between winning percentage and payroll in context of metro population.

Relationship between winning percentage and payroll in context of metro population.