richfitz / forest

New Phylogenetics Data Structures in R
Other
10 stars 0 forks source link

Fix up the `treeapply` function #9

Open richfitz opened 10 years ago

richfitz commented 10 years ago

We need an accumulate function (possibly call it a fold) and an apply function, and need to do this over the different iterator orders and over children etc, and with the target being a node or being the node data. So that we can do

treeapply(tr, order="post", target="data", function(x) x$foo)

to get all the foo elements out of the tree.

The current implementation is very very basic. Needs to work on subtrees, and allow iteration over at one of three levels:

Decide on how naming of output should go (names=TRUE)?

Write methods for dplyr's %.%? Or too silly?

richfitz commented 10 years ago

Something using Rcpp::Function seems worthwhile here. Get this written soon.