yml {ymlthis}R Documentation

Create a new yml object

Description

yml() initializes a yml object. yml objects create valid YAML and print it cleanly to the console. By default, yml() looks for your name (using getOption("usethis.full_name"), getOption("devtools.name"), and whoami::fullname()) and uses today's date to use in the author and date fields, respectively. If you've set default YAML in getOption("ymlthis.default_option") (see use_yml_defaults()), yml() will also use include those fields by default. yml_empty() is a wrapper that doesn't use any of these default YAML fields. yml() and all related⁠yml_*()⁠ functions validate that the results are indeed valid YAML syntax, although not every function is able to check that the input fields are valid for the setting they are used in.

Usage

yml(.yml = NULL, get_yml = TRUE, author = TRUE, date = TRUE)

yml_empty()

Arguments

.yml

a character vector, yml object, or YAML-like list. See details.

get_yml

logical. Use YAML stored in getOption("ymlthis.default_option")? By default, yml() includes if it exists.

author

logical. Get default author name?

date

logical. Get default date?

Details

.yml accepts a character vector of YAML, such as "author: Hadley Wickham", an object returned by ymlthis functions that start with ⁠yml_*()⁠, or a list object (e.g. list(author = "Hadley Wickham")). .yml objects are processed with as_yml(), a wrapper around yaml::yaml.load(). See that function for more details.

Value

a yml object

Examples


yml()

yml(date = FALSE)

"author: Hadley Wickham\ndate: 2014-09-12" %>%
  yml() %>%
  yml_title("Tidy Data") %>%
  yml_keywords(
    c("data cleaning", "data tidying", "relational databases", "R")
  )

yml() %>%
  yml_author(
    c("Yihui Xie", "Hadley Wickham"),
    affiliation = rep("RStudio", 2)
  ) %>%
  yml_date("07/04/2019") %>%
  yml_output(
    pdf_document(
    keep_tex = TRUE,
    includes = includes2(after_body = "footer.tex")
   )
  ) %>%
  yml_latex_opts(biblio_style = "apalike")


[Package ymlthis version 0.1.7 Index]