Debian Codegraph @

man/rllply.Rd

raw
1 % Generated by roxygen2: do not edit by hand
2 % Please edit documentation in R/attr_access.R
3 \name{rllply}
4 \alias{rllply}
5 \title{recursivly apply a function on a list}
6 \usage{
7 rllply(x, FUN, add_notation = FALSE, ...)
8 }
9 \arguments{
10 \item{x}{a list.}
11
12 \item{FUN}{a function to apply on each element of the list}
13
14 \item{add_notation}{logical. Should each node be
15 added a "position_type" attribute, stating if it is a "Branch" or a "Leaf".}
16
17 \item{...}{not used.}
18 }
19 \value{
20 a list with ALL of the nodes (from the original "x" list),
21 that FUN was applied on.
22 }
23 \description{
24 recursivly apply a function on a list - and returns the output as a list,
25 following the naming convention in the \code{plyr} package
26 the big difference between this and rapply is that this will also apply
27 the function on EACH element of the list, even if it's not a "terminal node"
28 inside the list tree.
29 An attribute is added to indicate if the value returned is
30 from a branch or a leaf.
31 }
32 \examples{
33 \dontrun{
34 x <- list(1)
35 x
36 rllply(x, function(x) {
37 x
38 }, add_notation = TRUE)
39
40 x <- list(1, 2, list(31))
41 x
42 rllply(x, function(x) {
43 x
44 }, add_notation = TRUE)
45 # the first element is the entire tree
46 # after FUN was applied to its root element.
47
48 hc <- hclust(dist(USArrests[1:4, ]), "ave")
49 dend <- as.dendrogram(hc)
50 rllply(dend, function(x) {
51 attr(x, "height")
52 })
53 rllply(dend, function(x) {
54 attr(x, "members")
55 })
56 }
57 }