futureverse / future.apply

:rocket: R package: future.apply - Apply Function to Elements in Parallel using Futures
https://future.apply.futureverse.org
211 stars 16 forks source link

future_by() should not accept specifying FUN as a character, because by() doesn't #106

Closed HenrikBengtsson closed 2 years ago

HenrikBengtsson commented 2 years ago

Despite:

> library(stats)
> y <- by(warpbreaks[, 1:2], warpbreaks[,"tension"], FUN = "summary")
Error in FUN(data[x, , drop = FALSE], ...) : 
  could not find function "FUN"

failing, we actually support:

> library(stats)
> library(future.apply)
> y <- future_by(warpbreaks[, 1:2], warpbreaks[,"tension"], FUN = "summary")
> str(y)
List of 3
 $ L: 'table' chr [1:6, 1:2] "Min.   :14.00  " "1st Qu.:26.00  " "Median :29.50  " "Mean   :36.39  " ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:6] "" "" "" "" ...
  .. ..$ : chr [1:2] "    breaks" "wool"
 $ M: 'table' chr [1:6, 1:2] "Min.   :12.00  " "1st Qu.:18.25  " "Median :27.00  " "Mean   :26.39  " ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:6] "" "" "" "" ...
  .. ..$ : chr [1:2] "    breaks" "wool"
 $ H: 'table' chr [1:6, 1:2] "Min.   :10.00  " "1st Qu.:15.25  " "Median :20.50  " "Mean   :21.67  " ...
  ..- attr(*, "dimnames")=List of 2
  .. ..$ : chr [1:6] "" "" "" "" ...
  .. ..$ : chr [1:2] "    breaks" "wool"
 - attr(*, "dim")= int 3
 - attr(*, "dimnames")=List of 1
  ..$ warpbreaks[, "tension"]: chr [1:3] "L" "M" "H"
 - attr(*, "call")= language future_by.data.frame(data = warpbreaks[, 1:2], INDICES = warpbreaks[, "tension"],      FUN = "summary")
 - attr(*, "class")= chr "by"

Action

HenrikBengtsson commented 2 years ago

Deprecation implemented in the develop branch.