compose | R Documentation |
Nest functions
compose(..., .list) x %.% y
... |
functions to be nested together |
.list |
alternatively an explicit list of functions.
If specified |
x |
a function |
y |
a function |
compose creates a functional composition of the listed functions. Functional composition of functions f and g is defined as f(g(.)). Order matters the right most function listed will be the innermost function in the composition, same with the operator version. To remember the order lists will be the order read out, i.e. compose(f,g) = f(g(x))
When using the operator version it is good to remember that parentheses are recommended see the examples
new function consisting of the functions nested
%.%
: infix compose operator
Andrew Redd
compose(any, is.na)(c(NA,1:3)) (sum%.%is.na)(c(1,NA)) #correct ## Not run: sum%.%is.an(NA) #incorrect ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.