Skip to contents

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

# \donttest{
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"))
# }