gt_render_image: Render 'gt' Table to Temporary png File

View source: R/gt_nfl.R

gt_render_imageR Documentation

Render 'gt' Table to Temporary png File

Description

Saves a gt table to a temporary png image file and uses magick to render tables in reproducible examples like reprex::reprex() or in package function examples (see details for further information).

Usage

gt_render_image(gt_tbl, ...)

Arguments

gt_tbl

An object of class gt_tbl usually created by gt::gt()

...

Arguments passed on to webshot2::webshot() and par().

Details

Rendering gt tables in function examples is not trivial because of the behavior of an underlying dependency: chromote. It keeps a process running even if the chromote session is closed. Unfortunately, this causes R CMD Check errors related to open connections after example runs. The only way to avoid this is setting the environment variable ⁠_R_CHECK_CONNECTIONS_LEFT_OPEN_⁠ to "false". How to do that depends on where and how developers check their package. A good way to prevent an example from being executed because the environment variable was not set to "false" can be taken from the source code of this function.

Value

Returns NULL invisibly.

Examples


tbl <- gt::gt_preview(mtcars)
gt_render_image(tbl)


nflplotR documentation built on Sept. 11, 2024, 9:01 p.m.