Learn R Programming

ymlthis: write YAML for R Markdown, bookdown, blogdown, and more

ymlthis makes it easy to write YAML front matter for R Markdown and related documents. yml_*() functions write functions and use_*() functions let you write the resulting YAML to your clipboard or to .yml files related to your project.

Installation

You can install ymlthis from CRAN with:

install.packages("ymlthis")

Or you can install the development version of ymlthis from GitHub with:

# install.packages("remotes")
remotes::install_github("r-lib/ymlthis")

Example

yml() creates a basic yml object returns simple YAML with the author and date.

library(ymlthis)

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

ymlthis supports many YAML arguments, with YAML-generating functions prefixed with yml_*():

yml() %>% 
  yml_author(c("Yihui Xie", "Hadley Wickham"), affiliation = "RStudio") %>% 
  yml_date(lubridate::today()) %>% 
  yml_output(
    word_document(keep_md = TRUE), 
    bookdown::html_document2()
  ) %>% 
  yml_citations(bibliography = "references.bib", csl = "aje.csl")
#> ---
#> author:
#> - name: Yihui Xie
#>   affiliation: RStudio
#> - name: Hadley Wickham
#>   affiliation: RStudio
#> date: '2022-06-24'
#> output:
#>   word_document:
#>     keep_md: true
#>   bookdown::html_document2: default
#> bibliography: references.bib
#> csl: aje.csl
#> ---

Add-in

ymlthis also includes an add-in that will create YAML for you and put it in a file, such as an .Rmd file, or on your clipboard.

Copy Link

Version

Install

install.packages('ymlthis')

Monthly Downloads

1,029

Version

0.1.7

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Malcolm Barrett

Last Published

August 5th, 2022

Functions in ymlthis (0.1.7)

is_yml

Is object a yml object?
includes2

Include content within output
use_yml_defaults

Set up default YAML
yml

Create a new yml object
use_yml

Copy YAML code to your clipboard or write to a new R Markdown file
use_yml_file

Write YAML to file
gitbook_config

Configure bookdown::gitbook() output
pkgdown_template

Generate a full YAML template for your pkgdown site
has_field

Check if field exists in YAML
read_json

Read and write to JSON and TOML
pagedown_business_card_template

Generate a full YAML template for your pagedown business card
last_yml

Return the most recently printed YAML
yml_handlers

Set handlers to process the way YAML is printed
yml_latex_opts

Set LaTeX YAML options for PDF output
yml_blank

Return a blank object to be discarded from YAML
yml_author

Set Top-level R Markdown YAML Fields
yml_blogdown_opts

Set Top-level YAML options for blogdown
yml_bookdown_opts

Set Top-level YAML options for bookdown
yml_resource_files

Add external resource files to R Markdown document
yml_clean

Remove intermediate rendering files
yml_replace

Replace, pluck, or discard top-level YAML fields
yml_citations

Set citation-related YAML options
yml_pkgdown

Set Top-level YAML options for pkgdown
yml_rticles_opts

Set YAML related to rticles output formats
yml_rsconnect_email

Set YAML for Scheduled Emails in RStudio Connect
yml_load

Load YAML from string
yml_toc

Specify Table of Contents options
yml_verbatim

Write YAML field or content verbatim
yml_vignette

Set up a package vignette
pandoc_template_types

Use pandoc templates and custom highlight themes
yml_code

Take code and write it as valid YAML
draw_yml_tree

Draw an tree of YAML hierarchy
code_chunk

Write code chunks programmatically
yml_runtime

Activate Shiny in R Markdown
yml_site_opts

Add site options for _site.yml and navbars for R Markdown websites
yml_output

Capture, validate, and write output YAML
yml_distill_opts

Set Top-level YAML options for distill
%>%

Pipe operator
yml_reference

Write references as YAML fields
yml_params

Parameterize an R Markdown report using Shiny components
yml_pagedown_opts

Top-level YAML options for pagedown
blogdown_template

Create YAML based on blogdown theme archetypes
bib2yml

Convert bib files to YAML
as_yml

Convert to yml object
asis_yaml_output

Export yml object as a YAML knitr code chunk