Translate team abbreviations into logos and render these images in html tables with the 'gt' package.
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
locationsis notNULL.- ...
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 argumentcolumns. Otherwise, the cell or set of cells to be associated with the team name transformation. Only thegt::cells_body(),gt::cells_stub(),gt::cells_column_labels(), andgt::cells_row_groups()helper functions can be used here. We can enclose several of these calls within alist()if we wish to make the transformation happen at different locations.
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")
)
)
# }

