Skip to contents

Translate team abbreviations into logos and render these images in column labels of 'gt' tables.

Usage

gt_sdv_cols_label(
  gt_object,
  columns = gt::everything(),
  league,
  height = 30,
  mark_type = c("logo", "wordmark", "headshot"),
  id_system = "auto",
  season = NULL,
  strict = FALSE
)

Arguments

gt_object

A table object created using gt::gt().

columns

The columns whose labels should be replaced with logos.

league

A league key from sdv_leagues().

height

The absolute height (px) of the image.

mark_type

One of "logo", "wordmark" or "headshot": whether the column names are teams (logo / wordmark) or player IDs (headshot).

id_system

How the column names are read. "auto" (the default) is sdv_logo_url()'s automatic reading for logo and wordmark labels, and means "espn" when mark_type = "headshot"; otherwise as in sdv_headshot_url().

season, strict

For logo and wordmark labels only (headshots take neither): the season whose mark to show, and whether an unresolved label is an error. With strict = TRUE every label that is not a team errors, including the non-team columns the default columns = gt::everything() takes.

Value

An object of class gt_tbl.

Examples

# \donttest{
library(gt)
library(sdvplotR)

df <- data.frame(
  KC = 1:3,
  BUF = 4:6,
  SF = 7:9
)

df |>
  gt() |>
  gt_sdv_cols_label(columns = c("KC", "BUF", "SF"), league = "nfl")
Kansas City Chiefs Buffalo Bills San Francisco 49ers
1 4 7
2 5 8
3 6 9
# }