Learn R Programming

yamlme (version 0.1.2)

coerce-methods: Coercing lists and rmd_doc objects

Description

Coercion of lists into rmd_doc objects and vice versa.

Objects of class rmd_doc can be created from lists or converted back to lists. This is convenient for defining functions that manipulate the content of such objects.

Usage

list2rmd_doc(object)

rmd_doc2list(object)

Arguments

object

Either a list or a rmd_doc object.

Examples

Run this code
## Create a document from a list
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")

## Convert back to a list
my_document <- as(my_document, "list")

Run the code above in your browser using DataLab