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

An image URL

scalar<character> // required

A url that resolves to an image file.

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".

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"
    )
  )