Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

reduce_right

Reduce from the right (retired)


Description

Soft-deprecated lifecycle

These functions are retired as of purrr 0.3.0. Please use the .dir argument of reduce() instead, or reverse your vectors and use a left reduction.

Usage

reduce_right(.x, .f, ..., .init)

reduce2_right(.x, .y, .f, ..., .init)

accumulate_right(.x, .f, ..., .init)

Arguments

.x

A list or atomic vector.

.f

For reduce(), and accumulate(), a 2-argument function. The function will be passed the accumulated value as the first argument and the "next" value as the second argument.

For reduce2() and accumulate2(), a 3-argument function. The function will be passed the accumulated value as the first argument, the next value of .x as the second argument, and the next value of .y as the third argument.

The reduction terminates early if .f returns a value wrapped in a done().

...

Additional arguments passed on to the mapped function.

.init

If supplied, will be used as the first value to start the accumulation, rather than using .x[[1]]. This is useful if you want to ensure that reduce returns a correct value when .x is empty. If missing, and .x is empty, will throw an error.

.y

For reduce2() and accumulate2(), an additional argument that is passed to .f. If init is not set, .y should be 1 element shorter than .x.


purrr

Functional Programming Tools

v0.3.4
GPL-3 | file LICENSE
Authors
Lionel Henry [aut, cre], Hadley Wickham [aut], RStudio [cph, fnd]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.