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 relatedyml_*() 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.

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?

Value

a yml object

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.

Examples


yml()
#> ---
#> date: '`r format(Sys.Date())`'
#> ---
#> 

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")
  )
#> ---
#> author: Hadley Wickham
#> date: '2014-09-12'
#> title: Tidy Data
#> keywords:
#> - data cleaning
#> - data tidying
#> - relational databases
#> - R
#> ---
#> 
# \donttest{
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")
#> ---
#> date: 07/04/2019
#> author:
#> - name: Yihui Xie
#>   affiliation: RStudio
#> - name: Hadley Wickham
#>   affiliation: RStudio
#> output:
#>   pdf_document:
#>     keep_tex: true
#>     includes:
#>       after_body: footer.tex
#> biblio-style: apalike
#> ---
#> 
# }