We have a function that requires multiple arguments without default values for any of them. However, even if some of them are not specified, the function returns a value, if these parameters are only used to subset a matrix (and possibly other types). We are puzzled why this is the case - can anybody help?
Specifically, why does the following code not return an error, but sums over the entire matrix and ignores j
:
foo <- function(mat, j){
v <- sum(mat[,j])
v
}
foo(mat = matrix(1:4,3,4))