Skip to content

sum and partial argument name matching

2 messages · Patrick Burns, Brian Ripley

#
"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

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.

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@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")
#
On Sat, 20 Nov 2004, Patrick Burns wrote:

            
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 don't see how there can be discussion: it breaks the stated rules for 
argument matching.