Ironclad
Ironclad

Reputation: 37

How to append date in R Markdown

How does one append the date in R Markdown to include say both the date created and the date last rendered to be on two separate lines. For example, I'd like the output on the first page to be:

Created on: October 21, 2018
Last Updated on: October 22, 2018

The Code I'm using is:

date: "Created on October 21, 2018"  #note two blank spaces before the next line
'`r paste("Last Updated on: ",format(Sys.Date(),"%B %d,%Y"))`'

Upvotes: 0

Views: 7222

Answers (1)

Dirk is no longer here
Dirk is no longer here

Reputation: 368181

Keep it simpler -- just put the fixed text inside the paste() function. In other words, make it for example

date: '`r paste("First created on Oct 01, 2018. Updated on", Sys.Date())`'

which would work as follows. You have all the control you need inside the paste(), so format(Sys.Date(), "%b %d, %Y") creates Oct 21, 2018.

enter image description here

Upvotes: 4

Related Questions