add_text_img: Add text and an image to the left or right of it

View source: R/gt_text_img.R

add_text_imgR Documentation

Add text and an image to the left or right of it

Description

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

title-car.png

See Also

Other Utilities: fa_icon_repeat(), fmt_pad_num(), fmt_pct_extra(), fmt_symbol_first(), generate_df(), gt_add_divider(), gt_badge(), gt_double_table(), gt_duplicate_column(), gt_fa_column(), gt_fa_rank_change(), gt_fa_rating(), gt_fa_repeats(), gt_highlight_cols(), gt_highlight_rows(), gt_img_border(), gt_img_circle(), gt_img_multi_rows(), gt_img_rows(), gt_index(), gt_merge_stack_color(), gt_merge_stack(), gt_two_column_layout(), gtsave_extra(), img_header(), pad_fn(), tab_style_by_grp()

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

gtExtras documentation built on Sept. 16, 2023, 1:08 a.m.