pipeR implements various function chaining methods: %>>%
operator,
Pipe
object, and pipeline
function. Each represents a distinct
pipeline model yet shares a common set of features designed to build
easy-to-read/write/maintain pipelines.
To learn more, please visit pipeR Tutorial.
pipeR package defines a set of syntax tailored for unified, intuitive piping experience. The package is designed to help organize code as a streamline that is consistent with logic and intuition.
The following example shows how traditional code can be written in different function chaining styles.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | # Traditional code:
plot(density(sample(mtcars$mpg, size = 10000, replace = TRUE),
kernel = "gaussian"), col = "red", main="density of mpg (bootstrap)")
# Operator-based pipeline using %>>%:
mtcars$mpg %>>%
sample(size = 10000, replace = TRUE) %>>%
density(kernel = "gaussian") %>>%
plot(col = "red", main = "density of mpg (bootstrap)")
# Object-based pipeline using Pipe():
Pipe(mtcars$mpg)$
sample(size = 10000, replace = TRUE)$
density(kernel = "gaussian")$
plot(col = "red", main = "density of mpg (bootstrap)")
# Argument-based pipeline using pipeline():
pipeline(mtcars$mpg,
sample(size = 10000, replace = TRUE),
density(kernel = "gaussian"),
plot(col = "red", main = "density of mpg (bootstrap)"))
# Expression-based pipeline using pipeline():
pipeline({
mtcars$mpg
sample(size = 10000, replace = TRUE)
density(kernel = "gaussian")
plot(col = "red", main = "density of mpg (bootstrap)")
})
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.