Re: [Rd] Strange behaviour of the [[ operator (PR#9263)

From: <murdoch_at_stats.uwo.ca>
Date: Sat 30 Sep 2006 - 13:09:12 GMT


On 9/29/2006 9:06 PM, Herve Pages wrote:
> Hi,
>
> This looks like a bug:
>
> > a <- list(b=5)
> > a[['b']]
> [1] 5
> > a[[t<-'b']]
>
> Nothing gets printed!
>
> I need to use parenthesis to see the expected result:
>
> > a[[(t<-'b')]]
> [1] 5

Yes, I agree it looks like a bug, and it's still there in R-devel. The problem is that the assignment sets the R_Visible flag to false, and the indexing never sets it to true. The same problem happens with a[t <- 'b'], whether a is a list or not:

 > a <- c(b=5, c=6, d=7)
 > a[t <- 'b']
 > .Last.value

b
5

Duncan Murdoch



R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Sat Sep 30 23:11:03 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sat 30 Sep 2006 - 17:30:11 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.