In R documentation, it explains that
The argument '...' can be used to allow one function to pass on argument settings to another.
I am not very sure how it works... In my imagination it is going to work like this:
Arithmetic <- function(x, ...) {
calculate <- function(x, y = 1, operand = "add") {
if (operand == "add") {return(x + y)}
if (operand == "subtract") {return(x - y)}
if (operand == "multiply") {return(x * y)}
if (operand == "devide") {return(x / y)}
}
return(calculate(x, y, operand))
}
Arithmetic(x = 3, y = 4, operand = "subtract")
## [1] -1
while what happens is:
Error in calculate(x, y, operand) : object 'operand' not found
So exactly how ...
works for user-defined functions in R?