From rgentlem at fhcrc.org  Sat Sep 30 20:10:11 2006
From: rgentlem at fhcrc.org (Robert Gentleman)
Date: Sat, 30 Sep 2006 11:10:11 -0700
Subject: [Rd] Strange behaviour of the [[ operator
In-Reply-To: <x2odsxz3ul.fsf@turmalin.kubism.ku.dk>
References: <451DC321.2030704@fhcrc.org>	<17694.33160.489389.196778@stat.math.ethz.ch>	<m2irj5e2d4.fsf@ziti.local>
	<x2odsxz3ul.fsf@turmalin.kubism.ku.dk>
Message-ID: <451EB303.2090003@fhcrc.org>

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




[Rd] Strange behaviour of the [[ operator
Robert Gentleman