Hao Zhu | f1873a4 | 2019-01-07 15:57:01 -0500 | [diff] [blame] | 1 | % Generated by roxygen2: do not edit by hand |
| 2 | % Please edit documentation in R/as_image.R |
| 3 | \name{as_image} |
| 4 | \alias{as_image} |
| 5 | \title{Render the table as an format-independent image and use it in rmarkdown} |
| 6 | \usage{ |
Hao Zhu | 62f5031 | 2019-01-15 15:19:29 -0600 | [diff] [blame] | 7 | as_image(x, width = NULL, height = NULL, file = NULL, ...) |
Hao Zhu | f1873a4 | 2019-01-07 15:57:01 -0500 | [diff] [blame] | 8 | } |
| 9 | \arguments{ |
| 10 | \item{x}{kable input. Either HTML or LaTeX} |
| 11 | |
| 12 | \item{width}{Image width in inches. (1 inch = 2.54 cm)} |
| 13 | |
| 14 | \item{height}{Image height in inches. (1 inch = 2.54 cm)} |
| 15 | |
Hao Zhu | b361fb5 | 2019-01-15 12:24:10 -0600 | [diff] [blame] | 16 | \item{file}{By default, as_image saves to an temp file, which works for |
| 17 | normal rmarkdown. However if you are using things like xaringan, which can't |
| 18 | be a standalone html, you can specify this file be the path you need, eg. |
| 19 | "img/something.png"} |
Hao Zhu | 62f5031 | 2019-01-15 15:19:29 -0600 | [diff] [blame] | 20 | |
| 21 | \item{...}{Additional arguments passed to save_kable.} |
Hao Zhu | f1873a4 | 2019-01-07 15:57:01 -0500 | [diff] [blame] | 22 | } |
| 23 | \description{ |
| 24 | This function generates a temporary png file using \code{save_kable} |
| 25 | and then try to put it in an rmarkdown document using |
| 26 | \code{knitr::include_graphics}. |
| 27 | } |
Hao Zhu | 9410a27 | 2020-08-03 01:11:47 -0400 | [diff] [blame^] | 28 | \examples{ |
| 29 | \dontrun{ |
| 30 | library(kableExtra) |
| 31 | |
| 32 | kable(mtcars, "latex", booktabs = T) \%>\% |
| 33 | kable_styling(latex_options = c("striped", "scale_down")) \%>\% |
| 34 | row_spec(1, color = "red") \%>\% |
| 35 | as_image() |
| 36 | } |
| 37 | } |