Skip to contents

The add_text_img function takes an existing gt_tbl object and adds some user specified text and an image url to a specific cell. This is a wrapper raw HTML strings and gt::web_image(). Intended to be used inside the header of a table via gt::tab_header().

Usage

add_text_img(text, url, height = 30, left = FALSE)

Arguments

text

A text string to be added to the cell.

url

A url that resolves to an image file.

height

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

left

A logical TRUE/FALSE indicating if text should be on the left (TRUE) or right (FALSE)

Value

An object of class gt_tbl.

Function ID

2-5

Figures

Examples

library(gt)
title_car <- mtcars %>%
  head() %>%
  gt() %>%
  gt::tab_header(
    title = add_text_img(
      "A table about cars made with",
      url = "https://www.r-project.org/logo/Rlogo.png"
    )
  )