[R] sum(..., na.rm=TRUE) oddity

Jim Lemon bitwrit at ozemail.com.au
Mon Apr 28 14:34:16 CEST 2003

Duncan Murdoch wrote:
> ...Is there ever any reason to name the summands?  I'd think it would be
> reasonable to generate an error, or at least a warning, in a case
> where any of the arguments to be summed are named.  For example
In parsing functions with an ellipsis in the argument list, R appears to 
consume unnamed arguments until it finds a recognized argument name or 
encounters an unresolvable data conflict. This is pretty reasonable 

> sum <- function (..., na.rm = FALSE) {
>   if (!is.null(names(list(...))))
>       stop(paste('Named summands:',paste(names(list(...)),collapse='
> ')))
>   .Internal(sum(..., na.rm = na.rm))
> }
> gives this:
> > sum(1,1,rm.na=TRUE)
> Error in sum(1, 1, rm.na = TRUE) : Named summands:   rm.na
What seems to be happening here is that you have explicitly named the 
argument, then supplied an argument with an name that cannot be resolved. 
I think the "misspelled argument name" is irrelevant to your original 


More information about the R-help mailing list