Partial functions are useful to define marginal distributions based on additional parameters.
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