Skip to contents

Call a function with all possible combinations of argument ranges

Usage

multicall(FUN, ..., fix. = names(formals(FUN))[1], max.combinations = 1000)

Arguments

FUN

function to be called

...

scalars or vectors named as the arguments that are accepted by FUN. From all objects with a name that is not in fix. combinations of their values are created and FUN is called with each of these combinations.

fix.

names of arguments to be kept constant

max.combinations

maximum number of argument combinations to be created at maximum

Examples

bmi <- function(mass, height) round(mass / (height * height), 1)

kwbGompitz:::multicall(
  bmi, mass = 60:70, height = seq(1.7, 1.8, 0.1), fix. = NULL
)
#>    mass height group    y
#> 1    60    1.7     1 20.8
#> 2    61    1.7     2 21.1
#> 3    62    1.7     3 21.5
#> 4    63    1.7     4 21.8
#> 5    64    1.7     5 22.1
#> 6    65    1.7     6 22.5
#> 7    66    1.7     7 22.8
#> 8    67    1.7     8 23.2
#> 9    68    1.7     9 23.5
#> 10   69    1.7    10 23.9
#> 11   70    1.7    11 24.2
#> 12   60    1.8    12 18.5
#> 13   61    1.8    13 18.8
#> 14   62    1.8    14 19.1
#> 15   63    1.8    15 19.4
#> 16   64    1.8    16 19.8
#> 17   65    1.8    17 20.1
#> 18   66    1.8    18 20.4
#> 19   67    1.8    19 20.7
#> 20   68    1.8    20 21.0
#> 21   69    1.8    21 21.3
#> 22   70    1.8    22 21.6