Skip to contents

Partial functions are useful to define marginal distributions based on additional parameters.

Usage

partial(f, ...)

Arguments

f

Function in two or more parameters.

...

Parameters to be held fixed for function f.

Value

Function object.

Details

This helper function stores passed arguments in a list, and stores this list in the environment of the returned function. Thus, it remembers the arguments that should be held fixed, such that the returned partial function now is a function with fewer arguments.

Examples

marginal <- partial(function(x, meanx) qnorm(x, meanx), meanx = 2)
marginal(0.5)
#> [1] 2