'R-Markdown (Powerpoint presentation) and expss-Table

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!



Solution 1:[1]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 stefan