Hello, I am using rmarkdown:::yaml_front_matter
to retrieve parameters from a Rmd
documents.
However when I use R code in those params, those expression are not evaluated
---
title: "Test"
author: "me"
output: html_document
params:
start_date: !r as.Date('2022-01-01')
end_date: as.Date('2022-01-31')
css: css/styles.css
warning: FALSE
out.width: "100%"
---
R> rmarkdown::yaml_front_matter("/tmp/test.Rmd")
$title
[1] "Test"
$author
[1] "me"
$output
[1] "html_document"
$params
$params$start_date
[1] "as.Date('2022-01-01')"
$params$end_date
[1] "as.Date('2022-01-31')"
$params$css
[1] "css/styles.css"
$params$warning
[1] FALSE
$params$out.width
[1] "100%"
Clearly something is done in rmarkdown:::yaml_front_matter
because I see !r
being "handled". So my question is: what should I do to evaluate R code, using eval(parse(text=...))
won't work in all generality