10

I have an R markdown file:

---
title: "Untitled"
author: "Me"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## R Markdown
This is an R Markdown document. 

As well as a DiagrammeR/mermaid chart:

graph LR
    A-->B

How can I add the chart in the R-markdown?

Oneira
  • 1,365
  • 1
  • 14
  • 28

1 Answers1

11

Actually it is trivial:

---
title: "Untitled"
author: "Me"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## R Markdown
This is an R Markdown document. 

```{r}
library(DiagrammeR)
mermaid("
graph LR
    A-->B
")
```
andschar
  • 3,504
  • 2
  • 27
  • 35
Oneira
  • 1,365
  • 1
  • 14
  • 28
  • 2
    This works well for me if the output format is HTML, but not if PDF/LaTex. Would you have any suggestions? – mavericks Feb 21 '20 at 10:13
  • If you know of any answer for LaTex/PDF, thank you for adding it here: https://stackoverflow.com/questions/60336847/diagrammer-mermaid-flowchart-in-rmarkdown-file-with-output-format-pdf-latex – mavericks Feb 21 '20 at 10:40