compose: Nest functions

Description Usage Arguments Details Value Author(s) Examples

Description

Nest functions

Usage

1
2
3
compose(..., .list)

x %.% y

Arguments

...

functions to be nested together

.list

alternatively an explicit list of functions. If specified ... will be ignored.

x

a function

y

a function

Details

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, ie. compose(f,g) = f(g(x))

When using the operator version it is good to remember that parentheses are recommended see the examples

Value

new function consisting of the functions nested

Author(s)

Andrew Redd

Examples

1
2
3
4
5
6
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)


Search within the dostats package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.