Search code examples
rr-markdownflexdashboardr-library

Including rmarkdown text in flexdashboard (includeMarkdown does not work) (R)


I would like to include external markdown file; however, I could not handle it on RStudio so far. If I manually copy/paste the content of about.md into main.R, there is no issue. I mean setting up everything related with flexdashboard is fine. On the other hand, I have tried to reinstall rmarkdown package and import it by library("rmarkdown"). This is not fair enough because flexdashboard has already its internal one. So it should not be related with whether the rmarkdown installed or not apart from flexdashboard installation. Any suggestions ? Thanks

I have prepared minimal code with its output as below: 'about.md'

test1
=======================================================================

**testttt**

testttt

**testttt2**

testttt

main.R

---
title: "test"
author: "test"
output: 
  flexdashboard::flex_dashboard:
    orientation: rows
    social: menu
    vertical_layout: fill
---

```{r setup, include=FALSE}

library(flexdashboard)
```

```{r}
  includeMarkdown('about.md')
```

The output:

Quitting from lines 17-18 (minimal.Rmd) 
Error in includeMarkdown("about.md") : 
  could not find function "includeMarkdown"
Calls: <Anonymous> ... handle -> withCallingHandlers -> withVisible -> eval -> eval
Execution halted

Solution

  • The function includemarkdown is from the package htmltools. So you have to load the library or use:

    ```{r}
    htmltools::includeMarkdown('about.md')
    ```