Description Usage Arguments Details Functions See Also Examples
Root IDs constitute the id of a stand alone expression. That is one that is not contained inside of another call or expression. The one exception to this is code blocks denoted by curly braces that are not themselves part of another call or expression; these we call code groups. In definition, A root node is defined to be a node that either has no parent or whose parent is a grouping node.
1 2 3 4 5 6 7 8 9 10 | pd_is_root(id, pd, ignore.groups = TRUE, .check = TRUE)
pd_all_root_ids(pd, include.groups = TRUE)
ascend_to_root(
id = pd$id,
pd = get("pd", parent.frame()),
ignore.groups = TRUE,
.check = TRUE
)
|
id |
id of the expression of interest |
pd |
The |
ignore.groups |
Should groupings be ignored? |
.check |
Perform checks for input validation? |
include.groups |
Include groups as root nodes (T) or descend into groups for roots? |
If ignore.groups=TRUE
then groupings are ignored and root nodes within the
group are interpreted as roots, otherwise nodes within a group are not
interpreted as root. Groupings are always interpreted as root if the
parent is 0 or if the parent is a group and also a root.
pd_is_root
: Test if a node is a root node
pd_all_root_ids
: give all root ids in pd
ascend_to_root
: ascend from id to root
see pd_is_grouping
for details on what a grouping is.
1 2 3 4 5 6 7 8 | # load example file and get_parse data
ex.file <- system.file("examples", "example.R", package="parsetools")
exprs <- parse(ex.file, keep.source = TRUE)
pd <- get_parse_data(exprs)
# There are 3 expressions so there should be three roots.
sum(pd_is_root(pd$id, pd))
roots <- pd_all_root_ids(pd)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.