[Rd] sum and partial argument name matching

Prof Brian Ripley ripley at stats.ox.ac.uk
Sat Nov 20 22:27:34 CET 2004


On Sat, 20 Nov 2004, Patrick Burns wrote:

> "sum" (and  perhaps  other functions?) allows partial argument
> name matching after its three-dots argument:
>
>> sum(1:4, NA, n=78, na.rm=FALSE)
> [1] 10
>> sum(1:4, NA, n=78, na.rm=TRUE)
> [1] 11

That's not `partial argument name matching', for the exact match should 
always win.  do_summary contains

     ans = matchArg(R_NaRmSymbol, &args);

and that is defined as

/* Destructively Extract A Named List Element. */
/* Returns the first partially matching tag found. */
/* Pattern is a symbol. */

The rest of the summary set (mean, min, max, prod) and also do_logic3 
(all, any) call matchArg and so have the same problem.

> I can see there could be a discussion about whether or not this is
> a bug, but I think all will agree that it's a might peculiar.

I don't see how there can be discussion: it breaks the stated rules for 
argument matching.

> This is done in 2.0.1 but the same behavior is in 1.8.1.
>
>> version
>        _             platform i386-pc-mingw32
> arch     i386          os       mingw32       system   i386, mingw32 status 
> major    2             minor    0.1           year     2004          month 
> 11            day      15            language R 
>
>
> Patrick Burns
>
> Burns Statistics
> patrick at burns-stat.com
> +44 (0)20 8525 0696
> http://www.burns-stat.com
> (home of S Poetry and "A Guide for the Unwilling S User")
>
> ______________________________________________
> R-devel at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-devel mailing list