as_image: Render the table as an format-independent image and use it in...

View source: R/as_image.R

as_imageR Documentation

Render the table as an format-independent image and use it in R Markdown

Description

This function generates a temporary png file using save_kable and then try to put it in an R Markdown document using knitr::include_graphics.

Usage

as_image(x, width = NULL, height = NULL, file = NULL, ...)

Arguments

x

kable input. Either HTML or LaTeX

width

Image width in inches. (1 inch = 2.54 cm)

height

Image height in inches. (1 inch = 2.54 cm)

file

By default, as_image saves to an temp file, which works for normal R Markdown. However if you are using things like xaringan, which can't be a standalone html, you can specify this file be the path you need, e.g. "img/something.png"

...

Additional arguments passed to save_kable.

Examples

## Not run: 
library(kableExtra)

kable(mtcars, "latex", booktabs = T) %>%
kable_styling(latex_options = c("striped", "scale_down")) %>%
row_spec(1, color = "red") %>%
as_image()

## End(Not run)

kableExtra documentation built on June 22, 2024, 10:59 a.m.