Message-ID: <CAM3-Kjbkiq3QVhiA9ym_GPEOdc4DttnpyXjmEXwcrt61RKBevA@mail.gmail.com>
Date: 2016-06-14T18:24:33Z
From: Marius Hofert
Subject: [R-pkg-devel] "multiple local function definitions for ‘FUN’ with different formal arguments"
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