renkun-ken / pipeR

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

Add documentation for the lazy evaluation feature of Pipe #23

Closed renkun-ken closed 10 years ago

renkun-ken commented 10 years ago

Pipe is lazily evaluated.

In ordinary cases where the Pipe object is directly printed out, the whole chain is evaluated immediately.

> Pipe(rnorm(100))$plot(col="red")

If the Pipe object is assigned to a symbol, for example,

> p <- Pipe(rnorm(100))$plot(col="red")

the chain of commands is not evaluated until p is printed or explicit evaluated like

> p
... some plot is produced ...

This lazy-evaluation feature of Pipe allows continuation of piping without evaluation. Consider working with ggvis.

> p <- Pipe(mtcars)$ggvis(~ mpg, ~ wt)
> p$layer_points()
$value : ggvis 
... a scatter plot is produced ...
> p$layer_bars()
$value : ggvis 
... a bar plot is produced ...