[R] sum(..., na.rm=TRUE) oddity
Peter Dalgaard BSA
p.dalgaard at biostat.ku.dk
Mon Apr 28 14:32:48 CEST 2003
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
More information about the R-help
mailing list