ggll ggll - 3 months ago 31
R Question

Using rmarkdown::render to set document header (title, author, date)

I am using

to create an HTML version of an R script. The output starts with script.r as title, my login as author, and the current
as date. I don't want to give away my login, nor my work schedule..

I know this metadata (title, author, date) can be set in a YAML block inside a
file, but I would like to avoid creating/editing this file, and work only with the original R script.

Is there a way to set (title, author, date) metadata via
, or other functions like

Alternatively, can this metadata be set inside the R script?

Please avoid suggesting that I should write an
file instead..


The Rmarkdown documentation (see ?compile_notebook) describes one way to do this by including a specially formatted comment in your script.R file.

For example, include this comment in your script to set the title, author and date.

#' ---
#' title: "Crop Analysis Q3 2013"
#' author: "John Smith"
#' date: "May 3rd, 2014"
#' ---

This will give you the following output: