# \donttest{
library(ggplot2)
library(dplyr, warn.conflicts = FALSE)
player_ids <- load_headshots() %>%
head(35) %>%
pull(savant_id)
# Build the player tiers data frame
# This is completely random!
df <- data.frame(
tier_no = sample(1:5, length(player_ids), replace = TRUE),
player_id = player_ids
) %>%
dplyr::group_by(tier_no) %>%
dplyr::mutate(tier_rank = sample(1:n(), n()))
# Plot player tiers
mlb_player_tiers(df)
# Create a combined tier which is useful for tiers with lots of players that
# should be split up in two or more rows. This is done by setting an empty
# string for the tier 5 description and removing the tier separation line
# below tier number 4.
# This example also shows how to turn off the subtitle and add a caption
mlb_player_tiers(df,
subtitle = NULL,
caption = "This is the caption",
tier_desc = c("1" = "MVP Candidates",
"2" = "Very Good",
"3" = "Medium",
"4" = "A Combined Tier",
"5" = ""),
no_line_below_tier = 4)
# For the development of the tiers, it can be useful to turn off image
# rendering as this can take quite a long time. By setting `devel = TRUE`, the
# headshots are replaced by player ids which is much faster
mlb_player_tiers(df,
tier_desc = c("1" = "MVP Candidates",
"2" = "Very Good",
"3" = "",
"4" = "A Combined Tier",
"5" = ""),
no_line_below_tier = c(2, 4),
devel = TRUE)
# }
Run the code above in your browser using DataLab