rmd_node_utilities | R Documentation |
Functions for extracting information for Rmd nodes.
rmd_node_label(x)
rmd_node_label(x) <- value
## Default S3 replacement method:
rmd_node_label(x) <- value
## S3 replacement method for class 'rmd_chunk'
rmd_node_label(x) <- value
rmd_node_type(x)
rmd_node_length(x)
rmd_node_content(x)
rmd_node_attr(x, attr)
rmd_node_engine(x)
rmd_node_options(x, yaml_style = TRUE)
rmd_node_code(x)
rmd_node_options(x) <- value
## Default S3 replacement method:
rmd_node_options(x) <- value
## S3 replacement method for class 'rmd_chunk'
rmd_node_options(x) <- value
rmd_node_attr(x, attr) <- value
## Default S3 replacement method:
rmd_node_attr(x, attr) <- value
## S3 replacement method for class 'rmd_node'
rmd_node_attr(x, attr) <- value
rmd_node_content(x) <- value
## Default S3 replacement method:
rmd_node_content(x) <- value
## S3 replacement method for class 'rmd_chunk'
rmd_node_content(x) <- value
## S3 replacement method for class 'rmd_raw_chunk'
rmd_node_content(x) <- value
## S3 replacement method for class 'rmd_markdown'
rmd_node_content(x) <- value
## S3 replacement method for class 'rmd_code_block'
rmd_node_content(x) <- value
## S3 replacement method for class 'rmd_code_block_literal'
rmd_node_content(x) <- value
rmd_node_set_label(x, value)
rmd_node_set_options(x, ...)
rmd_node_set_content(x, value)
rmd_node_set_attr(x, attr, value)
x |
An rmd object, e.g. |
value |
The new value to assign (for assignment functions). |
attr |
Attribute name to extract or set. |
yaml_style |
logical, if |
... |
For |
rmd_node_label()
- returns a character vector of node labels,
nodes without labels return NA
.
rmd_node_label<-()
- assigns new labels to chunk nodes. For the setter, returns the modified object.
rmd_node_type()
- returns a character vector of node types.
rmd_node_length()
- returns an integer vector of node lengths (i.e. lines of code, lines of text, etc.),
nodes without a length return NA
.
rmd_node_content()
- returns the raw character vector(s) of node textual content (lines/code), nodes without content return NULL
.
rmd_node_attr()
- returns the value of a given node attribute (S7 property), returns NULL
if the attribute does not exist.
rmd_node_engine()
- returns a character vector of chunk engines,
NA
for all other node types.
rmd_node_options()
- returns a list of chunk node options (named list), NULL
for all other node types. Option names are returned in YAML style (with hyphens) by default, or normalized style (with dots) if yaml_style = FALSE
.
rmd_node_options<-()
- assigns new options to chunk nodes by merging with existing options. Takes a named list of options. For the setter, returns the modified object.
rmd_node_attr<-()
- assigns new attribute values to nodes. For the setter, returns the modified object.
rmd_node_code()
- returns a list of chunk node code (character vector),
NULL
for all other node types.
rmd_node_set_label()
- pipeable version of rmd_node_label<-()
for setting node labels.
rmd_node_set_options()
- pipeable version of rmd_node_options<-()
for setting chunk options.
rmd_node_set_attr()
- pipeable version of rmd_node_attr<-()
for setting node attributes.
rmd_node_content<-()
- assigns new content to nodes. For the setter, returns the modified object.
rmd_node_set_content()
- pipeable version of rmd_node_content<-()
for setting node content.
rmd = parse_rmd(system.file("examples/hw01.Rmd", package="parsermd"))
rmd_node_label(rmd)
rmd_node_type(rmd)
rmd_node_content(rmd)
rmd_node_attr(rmd, "level")
rmd_node_engine(rmd)
rmd_node_options(rmd)
rmd_node_code(rmd)
chunk = rmd_chunk("r", "example", code = "1 + 1")
rmd_node_label(chunk)
rmd_node_label(chunk) = "new_name"
rmd_node_label(chunk)
rmd_node_options(chunk) = list(eval = FALSE, echo = TRUE)
rmd_node_options(chunk)
rmd_node_attr(chunk, "engine") = "python"
rmd_node_attr(chunk, "engine")
rmd_node_content(chunk) = c("x = 2", "y = 3")
rmd_node_content(chunk)
chunk = rmd_chunk("r", "example", code = "1 + 1") |>
rmd_node_set_label("new_label") |>
rmd_node_set_options(eval = FALSE, echo = TRUE) |>
rmd_node_set_content(c("a = 1", "b = 2"))
rmd_node_label(chunk)
rmd_node_options(chunk)
rmd_node_options(chunk, yaml_style = FALSE) # get in normalized style
rmd_node_content(chunk)
chunk = rmd_chunk("r", "example", code = "x = 1") |>
rmd_node_set_attr("engine", "python")
rmd_node_engine(chunk)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.