gt_mlb_column_labels: Replace Team Abbreviations/Player IDs With Images In Column...

View source: R/gt_helpers.R

gt_mlb_column_labelsR Documentation

Replace Team Abbreviations/Player IDs With Images In Column Labels

Description

gt_mlb_column_labels takes in a value of a team abbreviation or player id and converts the designated column to the corresponding image.

Usage

gt_mlb_column_labels(
  value,
  type = c("mlb_logo", "scoreboard_logo", "dot_logo", "headshot", "dot_headshot"),
  height = 30,
  na_headshot_to_logo = TRUE
)

Arguments

value

What team abbreviation/player id should be replaced with an image?

type

What type of image is replacing the value?

height

The absolute height (px) of the image

should NA/non player id matches return the MLB logo instead of a grayed out blank headshot? Ignored unless value is equal to "headshot". Defaults to TRUE

Value

HTML tag for image

Examples


library(gt)
library(mlbplotR)

df <- data.frame(BAL = 1,
                 TEX = 1,
                 LAD = 1,
                 "Mike_Trout" = 1,
                 "Shohei_Ohtani" = 1
                 )

gt_column_example <- df %>%
  gt::gt() %>%
  gt::cols_label(BAL = gt_mlb_column_labels("BAL", "mlb_logo"),
                 TEX = gt_mlb_column_labels("TEX", "scoreboard_logo"),
                 LAD = gt_mlb_column_labels("LAD", "dot_logo"),
                 "Mike_Trout" = gt_mlb_column_labels(545361, "dot_headshot"),
                 "Shohei_Ohtani" = gt_mlb_column_labels(660271, "headshot"))


camdenk/mlbplotR documentation built on Nov. 18, 2024, 10:29 p.m.