Displaying 1 result from an estimated 1 matches for "ndotarg".
Did you mean:
ndotargs
2004 Nov 09
1
Need car() and cdr() for '...'
Needed to redefine function "sum" for my MATLAB package.
There's something similar in Chambers's Green Book (pg 351)
so I modified it as such:
library(methods)
setGeneric("sum", function(x, ..., na.rm = FALSE) {
if (nDotArgs(...) > 0)
sum(c(sum(x, na.rm = na.rm),
sum(..., na.rm = na.rm)))
else
standardGeneric("sum")
})
setMethod("sum", "vector", function(x, na.rm) {
return(base::sum(x, na.rm));
})
setMethod("sum", "matrix", func...