Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Lightbox" for tables

Tags:

r

quarto

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")
```
like image 961
Julian Avatar asked Sep 08 '26 06:09

Julian


1 Answers

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")
```
like image 200
Julian Avatar answered Sep 11 '26 17:09

Julian



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!