R/filter_functions.R

Defines functions filter_functions

  filter_functions <- function(fun_names, is_prob_payoff = TRUE) {

  valid_funs <- fun_names[sapply(fun_names, function(fun_name) {
    exists(fun_name, mode = "function") 
  })]

  missing_funs <- setdiff(fun_names, valid_funs)
  missing_funs <- setdiff(missing_funs, "leftover")

  if (length(missing_funs) > 0 & is_prob_payoff) {
    stop(paste("The following function(s) are used in the twig but are not defined:", paste(missing_funs, collapse = ", ")), call. = FALSE)
  }

  return(valid_funs)
}

Try the twig package in your browser

Any scripts or data that you put into this service are public.

twig documentation built on April 12, 2025, 2:08 a.m.