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.
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 should download into 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”.
Read the data in from the file and save it as a tbl called “relative_payroll”
Make a histogram of team winning percentages. Play around with different binwidths.
Make a histogram of the relative payrolls.
Make a scatterplot with relative payroll on the horizontal axis and winning percentage on the vertical axis.
Without executing the code below, discuss with your group and see if you can figure out what it is doing.
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.
Add an appropriate title and relabel the y-axis using the
labs()
function to the plot above.