Description Usage Arguments Details Value Functions Examples
Common functions used in functional programming. These are similar to their
respective counterparts in Base R: Map
, Reduce
,
Filter
, etc. However, they take any value that can be converted
to a function via lambda
and the function comes after the argument
in the argument list for convenience while piping.
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 |
x |
vector |
f |
function to be applied to |
... |
additional arguments supplied to |
simplify |
logical; should the results be simplified to an array? |
USE.NAMES |
logical; should |
FUN.VALUE |
template vector for the return type |
clust |
cluster to use for |
init |
object used to initialize |
right |
logical; should the reduction start from left (default) or right? |
map
is slightly different from Map
in Base R other than
the argument order. First, iter
is applied to the vector x
so that users can define behavior for custom classes. Second, lambda
is applied to f
. map
only works for a single vector. Use mapn
to use multiple vectors as the function argument. The map
functions are
wrappers around sapply
or link[base]{vapply}
(if FUN.VALUE
is provided).
The other functions behave similar to what one would expect, with the exception
of accumulate
. accumulate
does not produce all intermediate results;
it only provides the final cumulative vector.
compose
takes multiple functions and produces a single "composed" function.
When the composed function is called, each function in the list is applied sequentially
to the arguments. The functions can be retrieved from the composed function's
attributes.
determined by the return value of the function f
.
map
: Apply function f
using elements in vector x
at each index.
mapn
: Apply function f
using the element in all elements in vectors ...
at each index as arguments.
ffind
: Find the position of elements in vector x
that satisfy predicate function f
.
filter
: Extract elements in vector x
that satisfy predicate function f
.
reduce
: Combine elements in a vector x
using binary function f
.
accumulate
: Combine elements in a vector x
using binary function f
, accumulating the results.
compose
: Combine functions into a single function.
1 2 3 4 5 6 7 8 9 10 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.