# NOT RUN {
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)
# }
Run the code above in your browser using DataLab