[R] Summary: recursion over list
Thomas Lumley
tlumley at u.washington.edu
Thu Jun 13 18:09:10 CEST 2002
On Thu, 13 Jun 2002, Eric Lecoutre wrote:
>
> - Thomas Lumley proposes a version that allows to do the same job without
> having to flatten the list:
>
> treeapply<-function (x, FUN)
> {
> if (is.atomic(x)) FUN(x)
> else lapply(x, function(n) treeapply(n, FUN))
> }
>
> Once again, all elements are not handled: I am considering any possible
> list: a list containing a function would not be handled.
though the revised version I posted a few hours later allowed the user to
specify a function that detected terminal nodes. This *can't* be
completely generic, as it's quite possible that the terminal nodes could
in fact be lists (eg if they are objects).
-thomas
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list