node-text | R Documentation |
Those functions extract the code corresponding to the node(s):
node_text()
applies on a single node, for example the output of
node_get_match()
node_text_all()
applies on a list of nodes, for example the output of
node_get_multiple_matches()
node_text(x)
node_text_all(x)
x |
A node, either from |
A list with as many elements as there are in the input. Each element is a list itself with the text corresponding to the input.
src <- "x <- rnorm(100, mean = 2)
any(duplicated(y))
plot(mtcars)
any(duplicated(x))"
root <- src |>
tree_new() |>
tree_root()
# node_text() must be applied on single nodes
root |>
node_find(ast_rule(pattern = "plot($A)")) |>
node_text()
# node_find_all() returns a list on nodes on which
# we can use node_text_all()
root |>
node_find_all(ast_rule(pattern = "any(duplicated($A))")) |>
node_text_all()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.