I wrote a simple function that takes a default argument and that also makes use of the ellipsis (...
):
myFun <- function(resize = NULL, ...) {
dots <- list(...)
str(dots)
}
However, when I try to pass an argument that is similar to the default argument, it is not recognized:
> myFun(res = 1)
list()
> myFun(resi = 2)
list()
However, if I use a different name it works fine:
> myFun(abc = 2)
List of 1
$ abc: num 2
> myFun(resize = 3, res = 1)
List of 1
$ res: num 1
Is this behavior intended? If so, is there a proper way to deal with this issue (besides renaming arguments)?
> sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.5.1 tools_3.5.1 yaml_2.2.0