Creates a racing bar chart to show map summary statistics over time and saves as a .gif file at a specified location.
Usage
homefield_racing(
  x,
  stat_name,
  output_file,
  title = "Racing Bar Chart",
  subtitle = "Value Label",
  caption = "Data Source"
)Arguments
- x
 Data frame created by homefield_stats() or including the following columns:
entity - identifies each entity (ex. school name - Iowa State, Minnesota, Bowling Green).
color - hexadecimal color to fill entity bars (ex. #cfab7a).
image - image url or local file path to be placed on entity bars.
time - date-times representing when each set of summary statistics was relevant.
stat_name - Summary statistic column with name specified by the stat_name argument. Examples from homefield_stats() include land, water, domain, and population.- stat_name
 (String required): Name of the summary statistic column which determines bar size and ordering.
- output_file
 (String required): Local file path ending in .gif.
- title
 (String required): Title of the map.
- subtitle
 (String required): Subtitle of the map. Usually indicates label of the summary statistic.
- caption
 (String required): Caption of the map. Usually includes provides credit to data origins.
Examples
if (FALSE) {
# Creating racing bar chart for cfb conquest maps in 2021
# undefeated for each week, 0 through 15
x_input <- list(cfb_conquest(season = 2021, week = 0),
               cfb_conquest(season = 2021, week = 1),
               cfb_conquest(season = 2021, week = 2),
               cfb_conquest(season = 2021, week = 3),
               cfb_conquest(season = 2021, week = 4),
               cfb_conquest(season = 2021, week = 5),
               cfb_conquest(season = 2021, week = 6),
               cfb_conquest(season = 2021, week = 7),
               cfb_conquest(season = 2021, week = 8),
               cfb_conquest(season = 2021, week = 9),
               cfb_conquest(season = 2021, week = 10),
               cfb_conquest(season = 2021, week = 11),
               cfb_conquest(season = 2021, week = 12),
               cfb_conquest(season = 2021, week = 13),
               cfb_conquest(season = 2021, week = 14),
               cfb_conquest(season = 2021, week = 15))
# time in weeks, 0 through 15
temporal_input <- lubridate::ymd(c("2021-08-28",
                                  "2021-09-04",
                                  "2021-09-11",
                                  "2021-09-18",
                                  "2021-09-25",
                                  "2021-10-2",
                                  "2021-10-9",
                                  "2021-10-16",
                                  "2021-10-23",
                                  "2021-10-30",
                                  "2021-11-6",
                                  "2021-11-13",
                                  "2021-11-20",
                                  "2021-11-26",
                                  "2021-12-4",
                                 "2021-12-11"))
temporal_stats <- homefield_stats(x = x_input,
                               temporal = temporal_input,
                               keep_max = FALSE,
                               keep_visuals = TRUE)
# converting land from square meters to square miles
temporal_stats_plot <- temporal_stats |>
 dplyr::mutate(land = land/2.59e6)
hf_racing(x = temporal_stats_plot,
               stat_name = "land",
               title = "2021 Season Week by Week - CFB Conquest homefield Map",
               subtitle = "Area in Square Miles",
               caption = "Data Source: cfbd.com",
               output_file = "C:/Users/darthvader/Downloads/cfb_conquest_2021_racing.gif")
}
