gt_fmt_mlb_headshot {mlbplotR}R Documentation

Render Player Headshots in 'gt' Tables

Description

gt_fmt_mlb_headshot takes 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
)

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 not NULL

height

The absolute height (px) of the image in the table cell

should NA/non matches return the MLB logo instead of a grayed out blank headshot? Defaults to TRUE

Value

An object of class gt_tbl.

Examples

library(gt)
library(mlbplotR)
gt_headshot_example <- mlbplotR::load_headshots() %>%
  head(5) %>%
  dplyr::select(player_name, savant_id) %>%
  gt::gt() %>%
  gt_fmt_mlb_headshot(columns = "savant_id")

[Package mlbplotR version 1.1.0 Index]