I was wondering if someone has an idea for a similar lightbox feature for tables in R. For instance, in the following MWE I have a table using kableExtra
with many columns that are thus displayed automatically using a scroll box since it is too wide. What I would like is a button or something to click on which than expands the table similar to the lightbox feature showing all columns.
---
title: "Lightbox and tables"
format: html
editor: source
execute:
warning: false
message: false
---
```{r}
library(dplyr)
library(kableExtra)
bind_cols(iris, iris, iris) |>
head(10) |>
kbl() |>
kable_styling(bootstrap_options = "condensed")
```
I found a solution using the as_image()
function:
---
title: "Lightbox Table Example"
format: html
filters:
- lightbox
lightbox: auto
execute:
warning: false
message: false
---
```{r}
#| lightbox:
#| description: We see our iris dataset here three times.
#| out.height: "50%"
library(dplyr)
library(kableExtra)
bind_cols(iris, iris, iris) |>
head(10) |>
kbl() |>
kable_styling(bootstrap_options = "condensed") |>
as_image(zoom = 1.5, file = "table_1.png")
```