Reputation: 12102
Say, I have an Rmd file that looks like this.
---
title: This is a title
subtitle: This is a subtitle
---
How can I access this variable title
in the Rmd file like below?
```{r}
print(title)
```
or
`r print(title)`
Upvotes: 2
Views: 769
Reputation: 769
You can access YAML metadata with rmarkdown::metadata
.
---
title: "This is a title"
output:
html_document
---
The title of this document is **`r rmarkdown::metadata$title`**
Upvotes: 2