[Rd] Strange behaviour of the [[ operator

Martin Maechler maechler at stat.math.ethz.ch
Sat Sep 30 16:39:04 CEST 2006

>>>>> "Herve" == Herve Pages <hpages at fhcrc.org>
>>>>>     on Fri, 29 Sep 2006 18:06:41 -0700 writes:

    Herve> Hi,
    Herve> This looks like a bug:
hmm, maybe...
or maybe not; I vaguely recall that this is documented somewhere...

    >> a <- list(b=5)
    >> a[['b']]
    Herve> [1] 5
    >> a[[t<-'b']]

    Herve> Nothing gets printed!

Yes, but that is not really much related to "[[" 
but rather to  "<-"  which momentarily turns off auto-printing.

Similar things happen in many similar circumstances.

    Herve> I need to use parenthesis to see the expected result:

    >> a[[(t<-'b')]]
    Herve> [1] 5

    Herve> Cheers,
    Herve> H.


More information about the R-devel mailing list