Skip to contents

This function generates R-Markdown documents by including the settings as arguments of the function. Comments and pieces of header can be also added through the argument append.


write_rmd(object, ...)

# S3 method for rmd_doc
write_rmd(object, filename, ...)



rmd_doc object used to write an Rmarkdown file. If header is missing, write_rmd() will fail with an error message.


Further arguments passed among methods (not yet used).


A character value with the name of the file to be written. It is not necessary to include the extension *.Rmd in this argument. If missing, the function will use the name of the input object.


A character vector of class rmd_doc and, if argument set for parameter filename, an Rmd file.


if (FALSE) {
my_document <- list(
  title = "Sample Document",
  author = "Miguel Alavarez",
  output = "html_document",
  body = txt_body(
    "# Intro",
    "This is just an example."
my_document <- as(my_document, "rmd_doc")
write_rmd(my_document, filename = file.path(tempdir(), "example"))