update_function_params: Update function default parameters

update_function_paramsR Documentation

Update function default parameters

Description

Update function default parameters

Usage

update_function_params(
  function_name = NULL,
  param_name = NULL,
  new_values = NULL,
  verbose = FALSE,
  ...
)

Arguments

function_name

function or character string referring to the name of a function, passed to formals().

param_name

character string of the argument/parameter name in formals() of the function_name.

new_values

list or named vector used to update or augment existing default argument values defined for param_name of formals() of function_name.

verbose

logical indicating whether to print verbose output.

...

additional arguments are ignored.

Details

This function is a minor extension to update_list_elements() intended to help update function parameters which are defined as a nested list. See examples.

The main utility is for a function that defines a full set of required argument values, where the user calling the function may want to modify onyl a subset of those default values.

See Also

Other jam utility functions: blockArrowMargin(), find_colname(), fold_to_log2fold(), get_se_assaydata(), gradient_rect(), handle_highlightPoints(), log2fold_to_fold(), logAxis(), outer_legend(), points2polygonHull(), update_list_elements()

Examples

# function uses y as passed to the function
test_function_1 <- function(y=list(a=1, b=4)) {
   print("y:");
   print(y);
}
test_function_1(y=list(b=5, d=1:5))

# function starts with y formals, adds or updates new values
test_function_2 <- function(y=list(a=1, b=4)) {
   y <- update_function_params(test_function_1,
      param_name="y",
      new_values=y);
   print("y:");
   print(y);
}
test_function_2(y=list(b=5:6, d=1:5))


jmw86069/jamma documentation built on Oct. 11, 2024, 7:08 a.m.