Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Including external markdown file covering inline code through includeMarkdown

I would like to include external markdown file covering inline code as well. Once I hit the Knit on RStudio, it does show only code text rather than the actual value of sys.time. If I place the content of about.md into the main.Rmd, there is no issue. The point should be related with includeMarkdown but it does not take any parameter except than path. Any suggestions ? Thanks in advance

main.Rmd

---
title: "test"
author: "test"
output: 
  flexdashboard::flex_dashboard:
    orientation: rows
    social: menu
    vertical_layout: fill
---
```{r}
  htmltools::includeMarkdown('about.md')
```

about.md

Today is `r format(Sys.time(), "%d %B %A %Y")`

Current Output

Today is r format(Sys.time(), "%d %B %A %Y")
like image 723
ozturkib Avatar asked Sep 21 '26 09:09

ozturkib


1 Answers

htmltools::includeMarkdown() only includes plain Markdown, not R Markdown. Your about.md is actually R Markdown---it contains R code to be evaluated.

To include an R Markdown document in another one, you can use the chunk option child:

```{r, child='about.Rmd'}
```

I suggest you rename about.md to about.Rmd.

like image 73
Yihui Xie Avatar answered Sep 23 '26 00:09

Yihui Xie



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!