lg_tm_value: Pull Salary Information and Team Aggregate Statistics

Description Usage Arguments Examples

View source: R/lg_tm_value.R

Description

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.

Usage

1
lg_tm_value(league, year, batting = T, start_year = NULL, end_year = NULL)

Arguments

league

Character league abbreviation. Either "AL" or "NL".

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.

Examples

 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")])

williazo/rwindow.baseball documentation built on May 29, 2019, 11:47 a.m.