I am working with a list of lists, collected from an XML chunk, that I would like to represent with object defined by the
data.tree package for R. The example below seems to work, and I can extract elements from the
data.tree representation of the list of lists. However, I cannot figure out how to use any of the text-formatting or visualization options (e.g.
igraph) due to the fact that "child" elements of each list are not uniquely labeled.
Ideally, I would like to recursively re-name "Children" with a serial number. For example, convert this:
Or even better, re-name the "Children" according to an attribute such as
Here is a similar question that is almost what I am looking for. I am not sure if the use of
data.tree functionality would simplify the re-naming of children elements, or if this should be done before initializing the
data.tree object. The tree-traversal capabilities of
data.tree seem like the right route, especially since the types of data I will be using can have multiple set of children, at any level.
A self-contained example:
# a typical list
l <- structure(list(RuleStart = structure(list(Children = structure(list(
RuleOperator = structure(list(Children = structure(list(RuleRule = structure(list(
Children = NULL, RefId = "49446"), .Names = c("Children",
"RefId")), RuleRule = structure(list(Children = NULL, RefId = "15976"), .Names = c("Children",
"RefId")), RuleRule = structur