Skip to content
Back to formatted view

Raw Message

Message-ID: <x2llxu3iq7.fsf@biostat.ku.dk>
Date: 2003-04-28T12:32:48Z
From: Peter Dalgaard
Subject: sum(..., na.rm=TRUE) oddity
In-Reply-To: <p46qav82rg5gqrcgngr8amsp9c70hmfm75@4ax.com>

Duncan Murdoch <dmurdoch at pair.com> writes:

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

I think you would quickly run into problems with cod that was using
constructions like do.call("sum",l) or sum(...) if you tried that. 

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907