use_yml() takes a yml object and puts the resulting YAML on your clipboard to paste into an R Markdown or YAML file. use_rmarkdown() takes the yml object and writes it to a new R Markdown file. You can add text to include in the body of the file. If it's not specified, use_rmarkdown() will use setup_chunk() by default. You can also set a default for body using options(ymlthis.rmd_body = "{your text}"); see use_rmd_defaults(). Together with specifying default YAML (see use_yml_defaults()), use_rmarkdown() also serves as an ad-hoc way to make R Markdown templates. You may also supply use_rmarkdown() with an existing R Markdown file from which to read the YAML header; the YAML header from the template is then combined with .yml, if it's supplied, and written to a new file. use_index_rmd() is a wrapper around use_rmarkdown() that specifically writes to a file called index.Rmd. By default, use_yml() and use_rmarkdown() use the most recently printed YAML via last_yml().

use_yml(.yml = last_yml())

use_rmarkdown(
  .yml = last_yml(),
  path,
  template = NULL,
  include_yaml = TRUE,
  include_body = TRUE,
  body = NULL,
  quiet = FALSE,
  open_doc = interactive(),
  overwrite = getOption("usethis.overwrite", FALSE)
)

use_index_rmd(
  .yml = last_yml(),
  path,
  template = NULL,
  include_yaml = TRUE,
  include_body = TRUE,
  body = NULL,
  quiet = FALSE,
  open_doc = interactive()
)

Arguments

.yml

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

path

A file path to write R Markdown file to

template

An existing R Markdown file to read YAML from

include_yaml

Logical. Include the template YAML?

include_body

Logical. Include the template body?

body

A character vector to use in the body of the R Markdown file. If no template is set, checks getOption("ymlthis.rmd_body") (see use_rmd_defaults()) and otherwise uses setup_chunk().

quiet

Logical. Whether to message about what is happening.

open_doc

Logical. Open the document after it's created? By default, this is TRUE if it is an interactive session and FALSE if not. Also checks that RStudio is available.

overwrite

Logical. If TRUE, overwrites the file without asking for permission. If FALSE, asks interactively if the user wishes to do so. Checks the user's usethis.overwrite option if set and is otherwise FALSE by default.

Value

use_yml() invisibly returns the input yml object