stat 579

Homework: web scraping

Due in class, Thursday/Monday Nov 19/23.

  1. For your favourite baseball team, write a script based on the code we used in class that downloads the batting statistics of all players for all seasons from 1986 to 2013. Write all the data into a single dataframe (make sure to include the year!). Include a separate column about the handedness of the player (the hand with which they bat. Clean the data set (make sure to get rid of all the extra symbols). Plot year versus OPS, connecting all results for the same player by a line.
  2. For a website of your choice, write the code necessary to download the information of a table into R. Base your code on the XML package.


Submit a R markdown file of your (documented!!) code. As a separate file submit a csv formatted file of the scraped data.

Great Answers: