Skip to content

More strange [[ behaviour

3 messages · Hervé Pagès, Duncan Murdoch

#
Hi,
[1] "MyList"
An object of class "MyList"
list()
Just testing
Just testing
Just testing
Just testing
...
Just testing
Just testing
Error in a[[x = 1]] : subscript out of bounds
Just testing
Just testing

Can someone explain me why the "[[x=1]]" case is treated differently?

Cheers,
H.
#
On 10/2/2006 3:21 PM, Herve Pages wrote:
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.

Duncan Murdoch
#
Duncan Murdoch wrote:
Hi Duncan,

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

Best,
H.