[R] Checks for partial matching (was Re: Variable passed to function not used in function in select=... in subset)

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Nov 11 23:27:11 CET 2008


On Tue, 11 Nov 2008, Duncan Murdoch wrote:

> On 11/11/2008 2:56 PM, Bert Gunter wrote:
>> Ummm... as today is still Armistice day  (in my time zone, anyway), maybe 
>> we
>> should call a truce and end this flame war...
>
> I haven't seen very many flames  --  there have been disagreements, but 
> generally it's been quite civil.  Certainly I don't think Berwin flamed me.
>
> If we were to add in a warning about partial name matching, it would have to 
> be accompanied by some way to deal with common uses like the one Berwin 
> mentioned.  (There are at least 100 uses of seq(..., length=...) in the core 
> & recommended packages.  I wouldn't want to fix all of those.)  But it could 
> still be useful, in the same way the checks for using TRUE and FALSE instead 
> of T and F are useful.

Actually we do already have such a check: see ?options (the warnPartial* 
options).  And when I checked a while back did discover and correct a lot 
of partial matches, about half a dozen or so of which were matching to the 
wrong thing.  From the NEWS for 2.6.0:

     o	New options 'warnPartialMatchDollar', 'warnPartialMatchArgs'
 	and 'warnPartialMatchAttr' to help detect the unintended use
 	of partial matching in $, argument matching and attr()
 	respectively.

I did at that time check if it were possible to change the arg names in 
seq(), but that horse has bolted since there are methods in public 
packages using the existing arg sequence.

-- 
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-help mailing list