recursivly apply a function on a list - and returns the output as a list,
following the naming convention in the plyr package
the big difference between this and rapply is that this will also apply
the function on EACH element of the list, even if it's not a "terminal node"
inside the list tree.
An attribute is added to indicate if the value returned is
from a branch or a leaf.
Usage
rllply(x, FUN, add_notation = FALSE, ...)
Arguments
x
a list.
FUN
a function to apply on each element of the list
add_notation
logical. Should each node be
added a "position_type" attribute, stating if it is a "Branch" or a "Leaf".
...
not used.
Value
a list with ALL of the nodes (from the original "x" list),
that FUN was applied on.
Examples
## Not run:
x <- list(1)
x
rllply(x, function(x){x}, add_notation = TRUE)
x <- list(1, 2, list(31))
x
rllply(x, function(x){x}, add_notation = TRUE)
# the first element is the entire tree
# after FUN was applied to its root element.
hc <- hclust(dist(USArrests[1:4,]), "ave")
dend <- as.dendrogram(hc)
rllply(dend, function(x){attr(x, "height")})
rllply(dend, function(x){attr(x, "members")})
## End(Not run)