Assume the following simple function:
test_function <- function(abc.def = 1){
print(abc.def)
}
Trying the following examples, we can note that:
> test_function ()
[1] 1
> test_function (abc.def = 3)
[1] 3
> test_function (abc = 2)
[1] 2
I'm interested in the call test_function (abc = 2)
, which manages to guess that abc
is abc.def
.
My question: why does this work? Does this behaviour have a name (and, hopefully, some further documentation)? Is it possible to block/disable this?
Unrelated note for context: I've noticed in rare cases that this can be confusing for students, where in specific cases if a function expects an argument say sigma.squared
, the function will work with just sigma
passed instead. There, however, without reading the documention the user would guess that the squared term is accounted for, meanwhile in reality it seems to be some sort of base R behaviour.