1

I recently discovered the package "expss" which is very useful in plotting tables. However, I would like to use such tables within powerpoint-presentations which I create using R-Markdown:

---
title: "A beautiful table"
author: "Michael Author"
date: "2/19/2022"
output: powerpoint_presentation
---

```{r echo=FALSE}
#install.packages("expss")
library(expss)
library(tidyverse)
```

```{r echo=FALSE}
mtcars %>%    
  expss::tab_cells(wt) %>%
  expss::tab_cols(carb) %>%
  expos::tab_stat_mean_sd_n() %>%
  expss::tab_pivot()
```

The code above should create a table like this:

 |    |              | carb |      |     |      |     |     |
 |    |              |    1 |    2 |   3 |    4 |   6 |   8 |
 | -- | ------------ | ---- | ---- | --- | ---- | --- | --- |
 | wt |         Mean |  2.5 |  2.9 | 3.9 |  3.9 | 2.8 | 3.6 |
 |    |    Std. dev. |  0.6 |  0.8 | 0.2 |  1.1 |     |     |
 |    | Unw. valid N |  7.0 | 10.0 | 3.0 | 10.0 | 1.0 | 1.0 |

But in Powerpoint it looks very unformatted: enter image description here

Does anyone know how I can fix this? Any other advice on how to easily create tables for powerpoint presentations would also be welcome (other packages). Thank you!

D. Studer
  • 1,711
  • 1
  • 16
  • 35

1 Answers1

2

One option would to convert your table to a huxtable using expss::as_huxtable.etable():

---
title: "A beautiful table"
author: "Michael Author"
date: "2/19/2022"
output: powerpoint_presentation
---

```{r echo=FALSE}
library(expss)
library(tidyverse)
```

```{r echo=FALSE}
mtcars %>%    
  expss::tab_cells(wt) %>%
  expss::tab_cols(carb) %>%
  expss::tab_stat_mean_sd_n() %>%
  expss::tab_pivot()  %>% 
  as_huxtable.etable()

```

enter image description here

stefan
  • 90,330
  • 6
  • 25
  • 51
  • 1
    Thanks, this works fine to me! Is there a way to further format this table with lines or background colors? – D. Studer Feb 21 '22 at 14:40
  • 1
    Not really familiar with either of these packages. But after converting to a Huxtable your could style the table using functionality offered by `huxtable`. See https://hughjonesd.github.io/huxtable/huxtable.html. But maybe you could do the same with `expss` – stefan Feb 21 '22 at 17:57