From amaliy1 at uic.edu  Wed Sep  6 05:50:30 2006
From: amaliy1 at uic.edu (Anil Maliyekkel)
Date: Tue, 5 Sep 2006 22:50:30 -0500
Subject: [Rd] (PR#9202) Re: Bugs with partial name matching
In-Reply-To: <Pine.LNX.4.64.0609051542310.17674@homer23.u.washington.edu>
References: <20060905014002.634C928F8E@slim.kubism.ku.dk>
	<Pine.LNX.4.64.0609051507530.17674@homer23.u.washington.edu>
	<Pine.LNX.4.64.0609051542310.17674@homer23.u.washington.edu>
Message-ID: <69C0202D-ED5A-495A-9F38-FD2F7F132C29@uic.edu>


On Sep 5, 2006, at 5:54 PM, Thomas Lumley wrote:
> The problem in
>> D = list(ABCD=2:1)
>>  D$ABC[]<-3:4
>> D
> $ABCD
> [1] 3 4
>
> $ABC
> [1] 3 4
>
> is that eval.c:evalseq ends up with a reference to D$ABCD from  
> evaluating D$ABC with partial matching.  Since evalseq doesn't (and  
> shouldn't) increase NAMED on these partially evaluated calls, NAMED  
> is still 1 for D$ABCD.  When evalseq's D$ABC has 3:4 assigned into  
> it the vector is changed directly, since NAMED=1, and both D$ABC  
> and D$ABCD change.

This problem does not appear when the following is done

 > D = list(ABCD=2:1)
 > D$ABC[]=c(3,4)
 > D
$ABCD
[1] 2 1

$ABC
[1] 3 4

Or when this is done:

 > D = list(ABCD=2:1)
 > D[["ABC"]][]=3:4
 > D
$ABCD
[1] 2 1

$ABC
[1] 3 4


But it does appear when the following is done:

 > D = list(ABCD=2:1)
 > X = 3:4
 > D$ABC[]=X
 > D
$ABCD
[1] 3 4

$ABC
[1] 3 4

But not when the following is done:
 > D = list(ABCD=2:1)
 > X = 3:4
 > X[1] = 1
 > D$ABC[]=X
 > D
$ABCD
[1] 2 1

$ABC
[1] 1 4

It appears to be a sequence specific bug for the $ operator, which  
might explain why it did not occur with my original examples where I  
had a character data column, but did appear where I had a numeric  
data column that was a sequence.

Going back to the original partial replacement problem, is there  
anyway to turn off partial matching, or to selectively apply exact  
matching when trying to access a single element?  I can get the  
desired single element match using the convoluted syntax D["ABC"] 
[[1]] and perform partial replacement operations on a new column.   
However, it would be nice to have single element access operator that  
does exact matching.

Anil




[Rd] (PR#9202) Re: Bugs with partial name matching
Anil Maliyekkel