Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

Set

Traverse a Tree and Assign Values


Description

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.

Usage

#OO-style:
# node$Set(..., 
#          traversal = c("pre-order", "post-order", "in-order", "level", "ancestor"),  
#          pruneFun = NULL, 
#          filterFun = NULL)
#traditional:
Set(nodes, ...)

Arguments

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.

Value

invisibly returns the nodes (useful for chaining)

See Also

Examples

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")

data.tree

General Purpose Hierarchical Data Structure

v1.0.0
GPL (>= 2)
Authors
Russ Hyde [ctb] (improve dependencies), Chris Hammill [ctb] (improve getting), Facundo Munoz [ctb] (improve list conversion), Markus Wamser [ctb] (fixed some typos), Pierre Formont [ctb] (additional features), Kent Russel [ctb] (documentation), Noam Ross [ctb] (fixes), Duncan Garmonsway [ctb] (fixes), Christoph Glur [aut, cre] (R interface)
Initial release
2020-07-31

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.