[R-pkg-devel] "multiple local function definitions for ‘FUN’ with different formal arguments"
Marius Hofert
marius.hofert at uwaterloo.ca
Tue Jun 14 20:24:33 CEST 2016
Hi,
I have a function A which calls a function B. B accepts an argument
'FUN' (a function). Depending on the choice of package, A constructs
FUN and passes it on to B:
A <- function(x, pkg = c("pkg1", "pkg2", "pkg3"), ...) {
pkg <- match.arg(pkg)
FUN <- switch(pkg,
"pkg1" = {
function(x, arg1, arg2) { }
},
"pkg2" = {
function(x, arg3, arg4, arg5) { }
},
"pkg3" = {
function(x, arg6) { }
},
stop("Wrong 'pkg'"))
B(x, pkg = pkg, FUN = FUN, ...)
}
Since different packages require a different structure of FUN, 'R CMD
check' shows:
* checking R code for possible problems ... NOTE
A: multiple local function definitions for ‘FUN’ with
different formal arguments
I can avoid the note by using three different names for FUN and then
another switch once B is called...
... but is there a more elegant solution? Also, is this a 'critical'
note for package submission to CRAN?
Cheers,
M
More information about the R-package-devel
mailing list