These functions add common top-level YAML fields for R Markdown documents, such as author, date, and title. Each takes a yml object and adds fields related to the function, as well as checking for duplicate fields and (where possible) checking for valid entries. yml_toplevel() is a catch-all function that will take any named R object and put in the top level of the YAML; it checks for duplicate fields but is unable to validate the input beyond that it is valid YAML syntax. Some R Markdown templates allow for additional variations of the YAML here. For instance, the distill package adds url and affiliation_url to the author field (see yml_distill_author, which wraps yml_author). Several yml_*() functions also contain ... which allow for these unique fields.

yml_author(.yml, name = NULL, affiliation = NULL, email = NULL, ...)

yml_date(.yml, date = NULL, format = "")

yml_title(.yml, title)

yml_subtitle(.yml, subtitle)

yml_abstract(.yml, abstract)

yml_keywords(.yml, keywords)

yml_subject(.yml, subject)

yml_description(.yml, description)

yml_category(.yml, category)

yml_lang(.yml, lang)

yml_toplevel(.yml, ...)

Arguments

.yml

a yml object created by yml(), as_yml(), or returned by a yml_*() function

name

A character vector, name of the author(s)

affiliation

The author's affiliation; must match length of name, e.g. if name has length of two, affiliation must as well; use NA if you don't want to include an affiliation for a given author.Note that not all formats support the affiliation field.

email

The author email address. Note that not all formats support the email field.

...

additional named R objects, such as characters or lists, to transform into YAML

date

The date; by default this is "`r format(Sys.Date())`", which will populate the date automatically.

format

When the default date is used, the format passed to format.Date().

title

A character vector, the title of the document

subtitle

A character vector, the subtitle of the document. Not all R Markdown formats use subtitles, so it may depend on what you use in the output field (see yml_output()). It is available in pdf_document(), html_document(), and word_document() by default.

abstract

A character vector, the abstract. Long character vectors are automatically wrapped using valid YAML syntax. This field is not available in all output formats; it is available in pdf_document() and html_document() by default.

keywords

A character vector of keywords. This field is not available in all output formats; it is available in pdf_document(), html_document(), word_document(), odt_document(), and powerpoint_presentation() by default.

subject

A character vector, the subject of the document. This field is not available in all output formats; it is available in pdf_document(), html_document(), word_document(), odt_document(), and powerpoint_presentation() by default.

description

A character vector, a description of the document. This field is not available in all output formats; it is available in word_document(), odt_document(), and powerpoint_presentation() by default.

category

A character vector, the category of the document. This field is not available in all output formats; it is available in word_document() and powerpoint_presentation() by default.

lang

The document language using IETF language tags such as "en" or "en-US". The Language subtag lookup tool can help find the appropriate tag.

Value

a yml object

See also

Examples

yml_empty() %>% yml_author("Yihui Xie") %>% yml_date("02-02-2002") %>% yml_title("R Markdown: An Introduction") %>% yml_subtitle("Introducing ymlthis") %>% yml_abstract("This paper will discuss a very important topic") %>% yml_keywords(c("r", "reproducible research")) %>% yml_subject("R Markdown") %>% yml_description("An R Markdown reader") %>% yml_category("r") %>% yml_lang("en-US")
#> --- #> author: Yihui Xie #> date: 02-02-2002 #> title: 'R Markdown: An Introduction' #> subtitle: Introducing ymlthis #> abstract: This paper will discuss a very important topic #> keywords: #> - r #> - reproducible research #> subject: R Markdown #> description: An R Markdown reader #> category: r #> lang: en-US #> --- #>