Call a Function with Argument Combinations from a Data Frame
Source:R/callWithData.R
callWithData.Rd
Call a Function with Argument Combinations from a Data Frame
Arguments
- FUN
function to be called
- data
data frame with one column per argument of
FUN
- ...
further (constant) arguments to
FUN
that are passed tomapply
viaMoreArgs
- threshold
if the ratio of unique value combinations in the relevant columns in data to all value combinations in these columns is below this threshold value then FUN will be called only with the unique value combinations. This should increase performance.
- SIMPLIFY
passed to
mapply
, default:TRUE
- USE.NAMES
passed to
mapply
, default:TRUE
Examples
combis <- expand.grid(x = 1:2, y = c(10, 20, 30))
combis
#> x y
#> 1 1 10
#> 2 2 10
#> 3 1 20
#> 4 2 20
#> 5 1 30
#> 6 2 30
callWithData(`+`, combis)
#> -> Calling +() for all 6 value combinations ... ok. (0.00 secs)
#> [1] 11 12 21 22 31 32