1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/attr_access.R
\name{rllply}
\alias{rllply}
\title{recursivly apply a function on a list}
\usage{
rllply(x, FUN, add_notation = FALSE, ...)
}
\arguments{
\item{x}{a list.}
\item{FUN}{a function to apply on each element of the list}
\item{add_notation}{logical. Should each node be
added a "position_type" attribute, stating if it is a "Branch" or a "Leaf".}
\item{...}{not used.}
}
\value{
a list with ALL of the nodes (from the original "x" list),
that FUN was applied on.
}
\description{
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.
}
\examples{
\dontrun{
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")
})
}
}
|