learning to use the data.tree structure
so i created a root nod
alltree<-Node$new("all")
then i got a df that i can attach to it
f<-structure(list(parent = c("all", "all", "all", "all", "all",
"all", "all", "all"), Kid = c("A", "B", "C", "D", "E", "F", "G",
"H"), ID = 1:8), .Names = c("parent", "Kid", "ID"), row.names = c(NA,
-8L), class = "data.frame")
f$pathString <- paste("all", f$Kid, sep = "/")
alltree <-as.Node(f)
so far so good, but i wanted to add another layer
d <- structure(list(SUBZONE = c("A1", "A2", "A3", "A4", "A8", "B10",
"B11", "B2", "B3", "B4"), ZONE = c("A", "A", "A", "A", "A", "B",
"B", "B", "B", "B"), ID = c(1L, 2L, 3L, 4L, 5L, 7L, 8L, 9L, 10L,
11L)), .Names = c("SUBZONE", "ZONE", "ID"), row.names = c(NA,
10L), class = "data.frame")
now how can i add it to the existing corresponding nodes? I do not want to recreate pathString, as it would wipe out the 2nd level fields ("ID").
d$pathString <- paste("all", d$ZONE,d$SUBZONE, sep = "/")
alltree <-as.Node(d)
Or is it just a tool limitation that I need to create it in one go - entire tree and then add fields/attributes? I have a tree 7 levels deep and would need to add attributes/fields at every level