yml_author: Set Top-level R Markdown YAML Fields

View source: R/yml_top.R

yml_authorR Documentation

Set Top-level R Markdown YAML Fields

Description

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.

Usage

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

Other yml: asis_yaml_output(), bib2yml(), draw_yml_tree(), has_field(), read_json(), use_yml_defaults(), use_yml_file(), use_yml(), yml_blogdown_opts(), yml_bookdown_opts(), yml_citations(), yml_clean(), yml_distill_opts(), yml_latex_opts(), yml_output(), yml_pagedown_opts(), yml_params(), yml_pkgdown(), yml_reference(), yml_replace(), yml_resource_files(), yml_rsconnect_email(), yml_rticles_opts(), yml_runtime(), yml_site_opts(), yml_toc(), yml_vignette()

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")


ymlthis documentation built on Aug. 5, 2022, 5:23 p.m.