I want to provide an optional function variable, let the functions check if this argument has been provided, and let it perform the corresponding set of calculations. I thought I could use the "..." operator for this.
The simplest example I can come up with (which, unfortunately, failed) is this:
monkeyfun = function(...){ if (exists("monkey")){ return('monkey found') } else { return('monkey not found') } }
Now monkeyfun(monkey=0) as well as monkeyfun() returning "monkey not found" .
As a health check, the definition of monkey = 1 outside the function works and returns "monkey found" .
The documentation for the argument '...' does not really help me understand this problem, and I could not find the wording of this question that gives the corresponding results here (I understand that this question is the main one and most likely is being discussed somewhere ) ...
I would really appreciate help on this.
source share