Review Lecture 2 Notes

Please spend a few minutes reading through the notes from Lecture 2. Like in Problem Set 1, you should go through each code block with someone in your group and see if you can both explain to each other what all of the code does.

Payroll and Winning Percentage in the MLB

In lecture, Prof. Wyner discussed the relationship between a team’s payroll and its winning percentage. We will create plots from his analysis in the following problems using the dataset “mlb_relative_payrolls.csv”, which you can find in the “data/” folder of your working directory. You should save all of the code for this analysis in an R script called “ps2_mlb_payroll.R”.

If you don’t have the dataset in your data folder yet, download it from the GitHub page here.

  1. Read the data in from the file and save it as a tbl called “relative_payroll”
## Parsed with column specification:
## cols(
##   Team = col_character(),
##   GM = col_character(),
##   Team_Payroll = col_double(),
##   Winning_Percentage = col_double(),
##   Year = col_double(),
##   Relative_Payroll = col_double()
## )
  1. Make a histogram of team winning percentages. Play around with different binwidths.

  2. Make a histogram of the relative payrolls.

  3. Make a scatterplot with relative payroll on the horizontal axis and winning percentage on the vertical axis.

  4. Without executing the code below, discuss with your group and see if you can figure out what it is doing.

  1. Execute the code above. What can you say about how team payrolls have evolved over time? Make a similar plot that visualizes how relative payrolls have evolved over time.

  2. Add an appropriate title and relabel the y-axis using the labs() function to the plot above.