renkun-ken / pipeR

Multi-Paradigm Pipeline Implementation
Other
169 stars 39 forks source link

Interfacing with data.tree #72

Open schnorr opened 7 years ago

schnorr commented 7 years ago

I've tried pipeR + the data.tree package, but pipelining won't work. The problem is that data.tree functions (such as Prune) change the object in-place, returning something unrelated with the object passed as parameter. Would you have an idea on how to interface with data.tree properly? I'd like to be able to do something like this:

library(data.tree);
library(pipeR);
atree <- df %>>%
          as.Node(mode="network") %>>%
          Prune(function(node) node$name != "data") %>>%
          Prune(function(node) !(node$Nature %in% c("Link", "Event")));

Normally, Prune expects a tree object in its first parameter, like this:

 Prune(atree, function(node) node$name != "data");

So, I was expecting in using the . to mark, such as this:

atree <- df %>>%
          as.Node(mode="network") %>>%
          Prune(., function(node) node$name != "data") %>>%
          Prune(., function(node) !(node$Nature %in% c("Link", "Event")));

But the problem is that Prune always returns the number of nodes removed. How can I tell pipeR to consider the modified . as input for the next Prune call? Is that possible?

Thanks for this nice package.