node-range | R Documentation |
Get the start and end positions of a node
node_range(x)
node_range_all(x)
x |
A node, either from |
A list of two elements: start
and end
. Each of those is a vector
with two values indicating the row and column. Those are 0-indexed.
src <- "x <- rnorm(100, mean = 2)
any(duplicated(y))
plot(x)
any(duplicated(x))"
root <- src |>
tree_new() |>
tree_root()
node_range(root)
root |>
node_find(ast_rule(pattern = "rnorm($$$A)")) |>
node_range()
# There is also an "_all" variant when there are several nodes per rule
root |>
node_find_all(
ast_rule(pattern = "any(duplicated($A))"),
ast_rule(pattern = "plot($A)")
) |>
node_range_all()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.