The method takes one or more vectors as an argument. It traverses the tree, whereby the values are picked
from the vector. Also available as OO-style method on Node.
#OO-style:
# node$Set(...,
# traversal = c("pre-order", "post-order", "in-order", "level", "ancestor"),
# pruneFun = NULL,
# filterFun = NULL)
#traditional:
Set(nodes, ...)The nodes on which to perform the Get (typically obtained via Traverse)
each argument can be a vector of values to be assigned. Recycled.
invisibly returns the nodes (useful for chaining)
data(acme)
acme$Set(departmentId = 1:acme$totalCount, openingHours = NULL, traversal = "post-order")
acme$Set(head = c("Jack Brown",
"Mona Moneyhead",
"Dr. Frank N. Stein",
"Eric Nerdahl"
),
filterFun = function(x) !x$isLeaf
)
print(acme, "departmentId", "head")
#> levelName departmentId head
#> 1 Acme Inc. 11 Jack Brown
#> 2 ¦--Accounting 3 Mona Moneyhead
#> 3 ¦ ¦--New Software 1
#> 4 ¦ °--New Accounting Standards 2
#> 5 ¦--Research 6 Dr. Frank N. Stein
#> 6 ¦ ¦--New Product Line 4
#> 7 ¦ °--New Labs 5
#> 8 °--IT 10 Eric Nerdahl
#> 9 ¦--Outsource 7
#> 10 ¦--Go agile 8
#> 11 °--Switch to R 9