[Rd] Strange behaviour of the [[ operator

Robert Gentleman rgentlem at fhcrc.org
Sat Sep 30 20:10:11 CEST 2006


True, re name matching, but I think we might want to consider a warning 
if they are supplied as the user may not be getting what they expect, 
regardless of the documentation....


Peter Dalgaard wrote:
> Seth Falcon <sfalcon at fhcrc.org> writes:
> 
>>> Similar things happen in many similar circumstances.
>> Here's a similar thing:
> 
> Not really, no?
>  
>>> v <- 1:5
>>> v
>> [1] 1 2 3 4 5
>>> v[mustBeDocumentedSomewhere=3]
>> [1] 3
>>
>> And this can be confusing if one thinks that subsetting is really a
>> function and behaves like other R functions w.r.t. to treatment of
>> named arguments:
>>
>>> m <- matrix(1:4, nrow=2)
>>> m
>>      [,1] [,2]
>> [1,]    1    3
>> [2,]    2    4
>>> m[j=2]
>> [1] 2
> 
> Or even
>> m[j=2,i=]
> [1] 2 4
> 
> However, what would the argument names be in the >2-dim case? i, j are
> used only in help("[") and that page is quite specific about
> explaining that named matching doesn't work. 
> 

-- 
Robert Gentleman, PhD
Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M2-B876
PO Box 19024
Seattle, Washington 98109-1024
206-667-7700
rgentlem at fhcrc.org




More information about the R-devel mailing list