Manipulate RMarkdown metadata from R code snippets

In short: is there a way to manipulate the RMarkdown metadata

-list generated from the YAML header from the following R code snippets? To illustrate this, I've tried the following:

---
title: "Untitled"
output: html_document
---

```{r}
rmarkdown::metadata$title <- "New title"
rmarkdown::metadata$title
```

      

This raises an error.

Error in rmarkdown::metadata$title <- "New title" : 
  Object 'rmarkdown' not found

      

Background

I am working on a TeX RMarkdown template. Some parts of the preamble need to be localized depending on the variable lang

defined in the YAML header. My current approach is to check the meaning metadata$lang

and create a list of matching terms. I wanted to add the contents of a list to metadata

and for example access terms in a TeX template via $loc_wordcount$

.

+3


source to share





All Articles