Skip to content
Prev 31282 / 398513 Next

sum(..., na.rm=TRUE) oddity

On Mon, 28 Apr 2003 12:28:32 +0100, Barry Rowlingson
<B.Rowlingson at lancaster.ac.uk> 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 

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:
Error in sum(1, 1, rm.na = TRUE) : Named summands:   rm.na

Duncan Murdoch