In RStudio, when I open a new R Markdown file, the default format has this nice feature where it writes in today's date into the YAML.
I would love for my custom templates in my own R packages to offer this feature but I cannot seem to do better than
---
title: ""
author: "Me"
date: '`r format(Sys.Date(), "%Y-%B-%d")`'
output: html_document
---
The problem with 'r format(Sys.Date(), "%Y-%B-%d")' is that it rewrites the date every time I knit the file, which is undesirable for my workflow. I'd rather maintain the date that the file was initiated.
You could use file.info like this
---
title: "title"
author: "Me"
date: '`r file.info("date.Rmd")$ctime`'
output: html_document
---
alternatively...
`r file.info(knitr::current_input())$ctime`
Assuming your markdown file is called date.Rmd.
Edited to add a more general method...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With