renkun-ken / pipeR

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

I(x) evaluates x first and pass x to parentheses evaluation #50

Closed renkun-ken closed 10 years ago

renkun-ken commented 10 years ago

I(x) provides a mechanism for meta piping, that is, evaluate the expression in I() first and put the result to ... in x %>>% (...).

> formula1 <- x ~ x + 2
> formula2 <- x ~ x * 2
> 1:10 %>>% I(if(mean(.) >= 5) formula1 else formula2)
 [1]  3  4  5  6  7  8  9 10 11 12

Therefore, the current implementation of I() is not enough. Use pipe_dot() in I().