Home > Software design >  Default Date Format in R Markdown
Default Date Format in R Markdown

Time:04-04

When I create an R Markdown (.Rmd) document, by default the date in the header is in the mm/dd/yyyy format, for example 4/3/2022. I would like to change it so that it displays the full name of the month followed by the year, for example April 2022. Currently, I have to change the date manually once the document is created, but is there some sort of global preference that allows the user to change default date format? I looked through all of the RStudio preferences but I didn't see anything related to the default date format for R Markdown. I also did a quick Google search, but most of the results seem to be focused on generating the date dynamically, whereas I would actually prefer to use the date that the document was created (i.e., static date).

CodePudding user response:

snippet

Tools > Global Options > Code > Edit Snippets or use usethis::edit_rstudio_snippets(). Space senstitive! enter image description here

Then when starting a new markdown doc, you can insert that snippet.

markdown template

For this, we should create a small package and install it.

  1. In a directory of choice, run pkgKitten::kitten("template")

  2. run usethis::use_rmarkdown_template()

  3. Edit the skeleton.Rmd or .yml file, in inst/rmarkdown/templates/*name/ to your liking. For inspiration or more advanced requirements, the enter image description here

  • Related