callWithData: Call a Function with Argument Combinations from a Data Frame

View source: R/callWithData.R

callWithDataR Documentation

Call a Function with Argument Combinations from a Data Frame

Description

Call a Function with Argument Combinations from a Data Frame

Usage

callWithData(
  FUN,
  data,
  ...,
  threshold = 0.5,
  SIMPLIFY = TRUE,
  USE.NAMES = TRUE
)

Arguments

FUN

function to be called

data

data frame with one column per argument of FUN

...

further (constant) arguments to FUN that are passed to mapply via MoreArgs

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 tomapply, default: TRUE

USE.NAMES

passed tomapply, default: TRUE

Value

vector of length nrow(data) with the result values returned by FUN

Examples

combis <- expand.grid(x = 1:2, y = c(10, 20, 30))
combis

callWithData(`+`, combis)

KWB-R/kwb.utils documentation built on April 1, 2024, 7:12 a.m.