Learn R Programming

data.tree (version 0.1.6)

Sort: Sort Children of a Node or an Entire Tree

Description

You can sort with respect to any argument of the tree.

Usage

Sort(attribute, ..., decreasing = FALSE, recursive = TRUE)

Arguments

attribute
a field, method or function. The result of the attribute determines the sorting. If it is a function, #' the attribute must take a Node as a first argument.
...
any parameters to be passed on the the attribute (in case it's a method or a function)
decreasing
sort order
recursive
if TRUE, Sort will be called recursively on the Node's children. This allows sorting an entire tree.

See Also

Node

Examples

Run this code
data(acme)
acme$Get("Aggregate", "cost", sum, assign = "totalCost")
acme$Sort("totalCost", decreasing = TRUE)
print(acme, "totalCost")

Run the code above in your browser using DataLab