renkun-ken / pipeR

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

Add syntax for questioning #35

Closed renkun-ken closed 10 years ago

renkun-ken commented 10 years ago

Consider the following syntax:

1:10 %>>% (? expr)

which prints the intermediate expression and returns x. It acts just like asking for the value of the lambda expression expr and continues piping with input x.

A demo:

> set.seed(100)
> rnorm(100) %>>%
+   (? mean(.)) %>>%
+   (? median(.)) %>>%
+   (? summary(.)) %>>%
+   plot(col="red")
? mean(.)
[1] 0.002912563
? median(.)
[1] -0.0594199
? summary(.)
     Min.   1st Qu.    Median      Mean   3rd Qu.      Max. 
-2.272000 -0.608800 -0.059420  0.002913  0.655900  2.582000