Kable (kableExtra) vertical scrollbar in knitted RMarkdown html_document?
Asked Answered
C

1

8

The vertical scrollbar generated with kableExtra works in RStudio but doesn't work in the knitted html_document.

Example

Take the following Rmd file

---
  output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, message = FALSE, warning = FALSE)
library(dplyr)
library(kableExtra)
```

```{r}
iris %>% 
  kable %>%
  kable_styling("striped", full_width = F)
```

When running the chunk in RStudio, I see a vertical scrollbar

enter image description here

But after knitting, the vertical scrollbar is gone and the whole data.frame is printed

enter image description here

How can I get the vertical scrollbar to display in the knitted HTML the same as it was in RStudio?

Contort answered 22/4, 2020 at 21:58 Comment(0)
B
13

Have a look at the function scroll_box() from the package kableExtra.

```{r}
iris %>% 
  kable %>%
  kable_styling("striped", full_width = F) %>% 
 scroll_box(width = "500px", height = "200px")
```

To specify the size of the box, see the arguments in the documentation

Buckthorn answered 23/4, 2020 at 6:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.