Message-ID: <20030428123416.BMJT28068.mta09.mail.mel.aone.net.au@there>
Date: 2003-04-28T12:34:16Z
From: Jim Lemon
Subject: sum(..., na.rm=TRUE) oddity
In-Reply-To: <p46qav82rg5gqrcgngr8amsp9c70hmfm75@4ax.com>
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
behavior.
> 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
question.
Jim