Description Usage Arguments Examples
Scrape data from https://www.baseball-reference.com to look at total salary statitics as well as overall team measures for pitching and hitting. Data is pulled by league with a row for each team in that league.
1 | lg_tm_value(league, year, batting = T, start_year = NULL, end_year = NULL)
|
league |
Character league abbreviation. Either |
year |
Numeric year. Default is to take the past full season if pulled in the offseason or the current season if pulled after opening day. |
batting |
Indicator variable to specify whether to pull batting or pitching value. By default it is set to batting. |
start_year |
Numeric value that identifies the beginning year to pull a range of data for the team of interest. This is an optional parameter. |
end_year |
Numeric value that identifies the ending year to pull a range of data for the team of interest. This is an optional parameter. |
1 2 3 4 5 6 7 8 9 10 | #pulling AL team batting values from the years 2009 to 2012
lg_tm_value("AL", start_year = 2009, end_year = 2012)
#pulling NL team values from most recent season
nl_pitching <- lg_tm_value("NL", batting = FALSE)
#team with the highest and lowest pitching WAR from 2017 season in the National League
rbind(nl_pitching[which(nl_pitching$WAR == max(nl_pitching$WAR)), c("Tm", "WAR")],
nl_pitching[which(nl_pitching$WAR == min(nl_pitching$WAR)), c("Tm", "WAR")])
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.