[Rd] More strange [[ behaviour

Herve Pages hpages at fhcrc.org
Mon Oct 2 22:21:45 CEST 2006


Duncan Murdoch wrote:
> On 10/2/2006 3:21 PM, Herve Pages wrote:
>>> a[[x=1]]
>> Error in a[[x = 1]] : subscript out of bounds
>>
>
> Indexing is a function call, with arguments x, i, j, ... .  If you use
> y=1, you're setting something in the "..." part of the arg list.  If
> you say x=1, you're setting the first arg, but because a[[x=1]] is the
> same as "[["(a, x=1), it is going to evaluate it as "[["(x=1, i=a) and
> try to index 1 by a instead of a by 1.
Hi Duncan,

Right, thanks for the explanation and sorry for not paying more
attention.

Best,
H.




More information about the R-devel mailing list