HomeGames | R Documentation |
Data mapping teams to the stadiums they played regular season games in as the home team.
data(HomeGames)
A data frame with 3233 observations on the following 9 variables.
year.key
Year
league.key
League; a factor with levels AA
AL
FL
NL
PL
UA
team.key
Team; a factor
park.key
Unique identifier for each ballpark
span.first
First date the park began acting as home field for the team
span.last
Last date the park began acting as home field for the team
games
Total games in this time span
openings
Total opening in this time span
attendance
Total attendance in this time span
Lahman, S. (2024) Lahman's Baseball Database, 1871-2023, 2024 version, http://www.seanlahman.com/
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.