Reputation: 4481
---
title: "Untitled"
output: powerpoint_presentation
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
## Table
```{r table, echo=FALSE, message=FALSE, warning=FALSE}
library(tidyverse)
library(kableExtra)
mtcars %>%
count(cyl) %>%
ungroup() # %>%
# kable() %>%
# kable_styling()
```
I'm working off the repro above. I'd like to present the mtcars calculated data frame in a kable or kableExtra fashion, like this:
Instead the table outputs in the following console format:
## # A tibble: 3 x 2
## cyl n
## <dbl> <int>
## 1 4 11
## 2 6 7
## 3 8 14
How do I make my R PowerPoint tables pretty, and even better, editable in PowerPoint?
Upvotes: 5
Views: 4956
Reputation: 10695
You can use flextable
package. It's support powerpoint_presentation output with R Markdown. You will find below an example :
---
title: "Untitled"
output: powerpoint_presentation
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
```
## Table
```{r table, echo=FALSE, message=FALSE, warning=FALSE}
library(magrittr)
library(flextable)
mtcars[1:5,1:4] %>%
tibble::rownames_to_column() %>%
flextable() %>%
set_header_labels(rowname = "") %>%
add_header_row(values = c("", "Group 1", "Group 2"),
colwidths = c(1, 2, 2)) %>%
theme_zebra() %>% autofit()
```
Upvotes: 6