View source: R/25_MatchFunc2Args.R
| MatchFunc2Args | R Documentation |
Identifies functions compatible with a given set of named arguments. A function is considered compatible if:
It has a ... parameter (loose matching), OR
All argument names in args_list exist in its formal parameters
(strict matching, default behavior).
MatchFunc2Args(
args_list,
...,
name_only = FALSE,
top_one_only = FALSE,
dots_enabled = FALSE
)
args_list |
Named list of arguments to match. Must have non-empty names when non-empty. |
... |
Functions to test for compatibility. |
name_only |
Logical. If |
top_one_only |
Logical. If |
dots_enabled |
Logical. If |
name_only = FALSE, top_one_only = FALSE: List of compatible function objects
name_only = TRUE, top_one_only = FALSE: Character vector of function identifiers
(named functions retain their symbol name; anonymous functions become "anonymous_<index>")
top_one_only = TRUE: Single function object or name (depending on name_only)
FilterArgs4Func() for filtering arguments to a function.(Reverse of this function)
## Not run:
f1 <- function(a, b) a + b
f2 <- function(x, y, ...) x * y
f3 <- function(p, q) p - q
args <- list(a = 1, b = 2)
# Strict matching (default): returns f1 only
MatchFunc2Args(args, f1, f2, f3)
# Loose matching: returns f1 and f2 (both accept 'a' and 'b' via strict match or ...)
MatchFunc2Args(args, f1, f2, f3, dots_enabled = TRUE)
# Return only function names
MatchFunc2Args(args, f1, f2, name_only = TRUE)
# Returns: c("f1", "f2") when dots_enabled=TRUE
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.