Output a nested list in RMarkdown list format

nested_list(x, pre = "", quote = "")

Arguments

x

The list

pre

Text to prefix to each line (e.g., if you want all lines indented 4 spaces to start, use " ")

quote

Text to quote values with (e.g., use "`" to make sure values are not parsed as markdown

Value

A character string

Examples

x <- list(
  a = list(a1 = "Named", a2 = "List"),
  b = list("Unnamed", "List"),
  c = c(c1 = "Named", c2 = "Vector"),
  d = c("Unnamed", "Vector"),
  e = list(e1 = list("A", "B", "C"),
           e2 = list(a = "A", b = "B"),
           e3 = c("A", "B", "C"),
           e4 = 100),
  f = "single item vector",
  g = list()
)
nested_list(x) 
#> * a: 
#>     * a1: Named
#>     * a2: List
#> * b: 
#>     1. Unnamed
#>     2. List
#> * c: 
#>     * c1: Named
#>     * c2: Vector
#> * d: 
#>     1. Unnamed
#>     2. Vector
#> * e: 
#>     * e1: 
#>         1. A
#>         2. B
#>         3. C
#>     * e2: 
#>         * a: A
#>         * b: B
#>     * e3: 
#>         1. A
#>         2. B
#>         3. C
#>     * e4: 100
#> * f: single item vector
#> * g: {empty}