Lovely day to you all!
I want to insert a mschart into an Rmd which I would like to knit to docx. I have no idea how to insert the plot. For "normal" docx this works:
ms_linechart(data = mtcars, x = "vs", y = "mpg", group = "gear") -> chart
doc <- read_docx()
doc <- body_add_chart(doc, chart = chart, style = "centered")
print(doc, target = "example.docx")
Here's my code so far which is not working:
---
date: "`r Sys.Date()`"
author: "Your Name"
title: "Untitled"
output:
officedown::rdocx_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE, fig.cap = TRUE)
library(officedown)
library(flextable)
library(officer)
library(mschart)
```
```{r}
body_add_chart(ms_linechart(data = mtcars, x = "vs", y = "mpg", group = "gear"))
```
Thanks for your help!