gt_mlb {mlbplotR}R Documentation

Add MLB team logos into rows of a gt table

Description

The gt_fmt_mlb_logo, gt_fmt_mlb_scoreboard_logo, and gt_fmt_mlb_dot_logo functions take an existing gt_tbl object and converts MLB team names from valid_team_names() into team logos. 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_logo(gt_object, columns, height = 30)

gt_fmt_mlb_scoreboard_logo(gt_object, columns, height = 30)

gt_fmt_mlb_dot_logo(gt_object, columns, height = 30)

Arguments

gt_object

An existing gt table object of class gt_tbl

columns

The columns wherein changes to cell data colors should occur.

height

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

Value

An object of class gt_tbl.

Examples

library(gt)
library(mlbplotR)

df <- data.frame(team = valid_team_names()[1:5],
                 logo = valid_team_names()[1:5],
                 scoreboard_logo = valid_team_names()[1:5],
                 dot_logo = valid_team_names()[1:5])

gt_logo_example <- df %>%
 gt::gt() %>%
 gt_fmt_mlb_logo(columns = "logo") %>%
 gt_fmt_mlb_scoreboard_logo(columns = "scoreboard_logo") %>%
 gt_fmt_mlb_dot_logo(columns = "dot_logo")

[Package mlbplotR version 1.1.0 Index]