You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Parallel reduce would allow you to specific arguments that varied across each call. Would be useful if you want to collapse many joins. Need to think if we could have some convention for naming input elements and matching with arguments.
Reacted by Connor McKay, mnist91 and Ljupcho Naumov
In terms of use case, I reach for reduce functions when adding cumulatively to an initial object. For instance with the officer package you can generate a powerpoint presentation. You start with an empty presentation and every function call adds a slide to the cumulative presentation. So instead of using pmap that would generate 50 presentations, I've needed a single presentation with 50 slides based on the same template, which sounds like preduce. The init is the starting empty template, and then every function call adds a slide. Some pseudo code:
Activity
hadley commentedon Mar 8, 2017
Note that the presence of init changes how the arguments align:
To match
pmap()the call might look like:but
varswould have length one less thandfs(which makes sense because of fence-posting). Maybe also needreduce2():Maybe just start with
reduce2()and leavepreduce()for now? Seems harder to imagine use case givenreduce2().Ljupch0 commentedon May 2, 2021
In terms of use case, I reach for reduce functions when adding cumulatively to an initial object. For instance with the
officerpackage you can generate a powerpoint presentation. You start with an empty presentation and every function call adds a slide to the cumulative presentation. So instead of using pmap that would generate 50 presentations, I've needed a single presentation with 50 slides based on the same template, which sounds like preduce. Theinitis the starting empty template, and then every function call adds a slide. Some pseudo code:I have working code of this example here. I needed to iterate a single vector so just
reduceworked, but a more generalpreducewould be fantastic: https://github.com/Ljupch0/stock_presentations/blob/master/Multiple%20Tickers.RMdmoodymudskipper commentedon May 31, 2021
I've been needing this too, the following seems to work fine :
.initis mandatory here, the intended use case is to have a data.frame of arguments to apply row-wise in sequence on an object passed through.initImplement reduce2