| HomeGames {Lahman} | R Documentation |
HomeGames table
Description
Data mapping teams to the stadiums they played regular season games in as the home team.
Usage
data(HomeGames)
Format
A data frame with 3200 observations on the following 9 variables.
year.keyYear
league.keyLeague; a factor with levels
AAALFLNLPLUAteam.keyTeam; a factor
park.keyUnique identifier for each ballpark
span.firstFirst date the park began acting as home field for the team
span.lastLast date the park began acting as home field for the team
gamesTotal games in this time span
openingsTotal opening in this time span
attendanceTotal attendance in this time span
Source
Lahman, S. (2023) Lahman's Baseball Database, 1871-2022, 2022 version, https://www.seanlahman.com/baseball-archive/statistics/
Examples
data(HomeGames)
library(dplyr)
# How many parks has every team played in as the home team for even a single game?
HomeGames %>%
count(team.key) %>%
arrange(team.key)
# What parks have the Toronto Blue Jays played in as the home team?
HomeGames %>%
filter(team.key == "TOR") %>%
arrange(span.last)
# What parks have the Boston Red Sox played in as the home team?
HomeGames %>%
filter(team.key == "BOS") %>%
arrange(span.last)
# What is the Toronto Blue Jays annual total home attendance by year?
HomeGames %>%
filter(team.key == "TOR") %>%
group_by(year.key) %>%
summarize(total.attendance = sum(attendance)) %>%
arrange(year.key)
[Package Lahman version 11.0-0 Index]