Skip to contents

The gt_img_rows function takes an existing gt_tbl object and converts filenames or urls to images into inline images. This is a wrapper around gt::text_transform() + gt::web_image()/gt::local_image() with the necessary boilerplate already applied.

Usage

gt_img_rows(gt_object, columns, img_source = "web", 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.

img_source

A string, specifying either "local" or "web" as the source of the images.

height

Height of image

scalar<numeric|integer> // default: 30

The absolute height of the image in the table cell (in "px" units). By default, this is set to "30px".

Value

An object of class gt_tbl.

Examples

library(gt)
teams <- "https://github.com/nflverse/nflfastR-data/raw/master/teams_colors_logos.rds"
team_df <- readRDS(url(teams))

 logo_table <- team_df %>%
   dplyr::select(team_wordmark, team_abbr, logo = team_logo_espn, team_name:team_conf) %>%
   head() %>%
   gt() %>%
   gt_img_rows(columns = team_wordmark, height = 25) %>%
   gt_img_rows(columns = logo, img_source = "web", height = 30) %>%
   tab_options(data_row.padding = px(1))

Figures

Function ID

2-7