gt_nfl_headshots | R Documentation |
Translate NFL player gsis IDs to player headshots and render these images in html tables with the 'gt' package.
gt_nfl_headshots(gt_object, columns, height = 30, locations = NULL)
gt_object |
A table object that is created using the |
columns |
The columns for which the image translation should be applied.
Argument has no effect if |
height |
The absolute height (px) of the image in the table cell. |
locations |
If |
An object of class gt_tbl
.
The logo and wordmark rendering functions gt_nfl_logos()
and
gt_nfl_wordmarks()
.
library(nflplotR)
library(gt)
# Silence an nflreadr message that is irrelevant here
old <- options(nflreadr.cache_warning = FALSE)
df <- data.frame(
player_gsis = c("00-0033873",
"00-0026498",
"00-0035228",
"00-0031237",
"00-0036355",
"00-0019596",
"00-0033077",
"00-0012345",
"00-0031280"),
player_name = c("P.Mahomes",
"M.Stafford",
"K.Murray",
"T.Bridgewater",
"J.Herbert",
"T.Brady",
"D.Prescott",
"Non.Match",
"D.Carr")
)
# Replace player IDs with headshot images
table <- gt(df) %>%
gt_nfl_headshots("player_gsis")
# Restore old options
options(old)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.