R markdown YAML dynamic variables

In RMarkdown, I seem to be able to create โ€œsomeโ€ dynamic variables in the YAML header, but not for others:

For example, this works:

---
title: 
  "Some Title, `r format(Sys.time(), '%d %B, %Y')`"
...
---

But it is not.

---
...
pdf_document:
    keep_tex: `r 'true'`
---

But this is DOES (i.e. not dynamic).

---
...
pdf_document:
    keep_tex: true
---

So, how can I โ€œdynamicallyโ€ assign keep_texeither true or false, what I want to do is something like this:

---
...
pdf_document:
    keep_tex: `r getOption('mypackage.keep_tex')`
---
+4
source share
1 answer

I do not know if it is possible to programmatically set the template parameters in the YAML header of the .Rmd file.

, rmarkdown::render , (pdf_document), (, keep_tex).

, .Rmd, "test.Rmd", :

---
title: 
  "Some Title, `r format(Sys.time(), '%d %B, %Y')`"
---

... , , TeX ,

my_keep <- TRUE

... PDF TeX :

render(input = "test.Rmd",
       output_format = pdf_document(keep_tex = my_keep))
+3

All Articles