inherit_default_params: Inherit default parameters from a list of super functions

Description Usage Arguments Value Examples

View source: R/inherit_default_params.R

Description

Inherit default parameters from a list of super functions

Usage

1
inherit_default_params(super_functions, fun)

Arguments

super_functions

A list of super functions of which 'fun“ needs to inherit the default parameters

fun

The function whose default parameters need to be overridden

Value

Function fun, but with the default parameters of the super_functions

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
fun1 <- function(a = 10, b = 7) runif(a, -b, b)
fun2 <- function(c = 9) 2^c

fun3 <- inherit_default_params(
  super = list(fun1, fun2),
  fun = function(a, b, c) {
    list(x = fun1(a, b), y = fun2(c))
  }
)

fun3

dynutils documentation built on March 22, 2021, 5:06 p.m.