gt_fmt_mlb_headshot
and gt_fmt_mlb_dot_headshot
take an existing gt_tbl
object and converts player ids into headshots.
This is a wrapper around
gtExtras::gt_image_rows()
written by Tom Mock, which is a wrapper around gt::text_transform()
+ gt::web_image()
/
gt::local_image()
with the necessary boilerplate already applied.
Usage
gt_fmt_mlb_headshot(
gt_object,
columns,
height = 30,
na_headshot_to_logo = TRUE
)
gt_fmt_mlb_dot_headshot(
gt_object,
columns,
height = 30,
na_headshot_to_logo = TRUE
)
Arguments
- gt_object
An existing gt table object of class
gt_tbl
- columns
The columns wherein changes to cell data colors should occur. Has no effect if
locations
is notNULL
- height
The absolute height (px) of the image in the table cell
- na_headshot_to_logo
should NA/non matches return the MLB logo instead of a grayed out blank headshot? Only has an effect with
gt_fmt_mlb_headshot
. Defaults toTRUE
Examples
# \donttest{
library(gt)
library(mlbplotR)
gt_headshot_example <- mlbplotR::load_headshots() %>%
head(5) %>%
dplyr::select(player_name, savant_id1 = savant_id, savant_id2 = savant_id) %>%
gt::gt() %>%
gt_fmt_mlb_headshot(columns = "savant_id1") %>%
gt_fmt_mlb_dot_headshot(columns = "savant_id2")
# }