Skip to contents

Translate team abbreviations into logos and render these images in html tables with the 'gt' package.

Usage

gt_wnba_logos(gt_object, columns, ..., height = 30, locations = NULL)

Arguments

gt_object

A table object that is created using the gt::gt() function.

columns

The columns for which the image translation should be applied. Argument has no effect if locations is not NULL.

...

Currently not in use

height

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

locations

If NULL (the default), the function will render logos in argument columns. Otherwise, the cell or set of cells to be associated with the team name transformation. Only the gt::cells_body(), gt::cells_stub(), gt::cells_column_labels(), and gt::cells_row_groups() helper functions can be used here. We can enclose several of these calls within a list() if we wish to make the transformation happen at different locations.

Value

An object of class gt_tbl.

Output of below example

Examples

# \donttest{
teams <- nbaplotR::valid_team_names("WNBA")
df <- data.frame(
  team_a = teams[1:6],
  logo_a = teams[1:6],
  team_b = teams[7:12],
  logo_b = teams[7:12]
)
# create gt table and translate team names to logos
table <- df |>
  gt::gt() |>
  nbaplotR::gt_wnba_logos(columns = gt::starts_with("logo")) |>
  gt::cols_label(
    gt::starts_with("team") ~ "TEAM",
    gt::starts_with("logo") ~ "LOGO"
  ) |>
  gt::tab_style(
    style = gt::cell_borders(side = "left"),
    locations = list(
      gt::cells_body(columns = "team_b"),
      gt::cells_column_labels(columns = "team_b")
    )
  )
# }