rmarkdown powerpoint: two kable on one slide

Viewed 174

In this example each kable is produced on one slide, even though the slide is large enough for 2.

---
title: "Untitled"
author: ""
date: "2/2/2022"
output: powerpoint_presentation
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE, message = FALSE, warning = FALSE, fig.height=5, fig.width=10)
```


## Slide with R Output

```{r}
knitr::kable(head(summary(cars),2))
```

```{r}
knitr::kable(head(summary(cars),2))
```

gives the output: enter image description here

How do I make both kable on one slide one after the other.

1 Answers

You can use the gridExtra package https://cran.r-project.org/web/packages/gridExtra/vignettes/tableGrob.html The documentation provides additional details about controlling formatting. I provided one example for illustration.

library(tidyverse)
library(gridExtra)
t1 <- 
head(summary(cars),2) %>% 
  tableGrob(theme = ttheme_minimal(), rows = NULL)

tt3 <- ttheme_minimal(
  core=list(bg_params = list(fill = blues9[1], 
                             col=NA),
            fg_params=list(fontface=3)),
  colhead=list(fg_params=list(col="navyblue", fontface=4L)))


t2 <- 
 head(summary(cars),2) %>% 
  tableGrob(theme = tt3, rows = NULL)

grid.arrange(t1 , t2)

Example slides

example Code

Related