error). If length(subscript)>1 then it gets treated
as an attempt to recursively extract an element of
a nested list.
list(10,20)[[-1]] # get the last element out of 2
list(10,20,30)[[-(1:2)]] # get the last of 3? No.
Error in list(10, 20, 30)[[-(1:2)]] :
attempt to select more than one element
list(10,list(20,30))[[-c(1:2)]] # see how recursive subscripting is
done
[1] 20
If negative subscripts were not allowed in [[ then
there might be a little less confusion about [[.
I agree, it would be better not to allow negatives here, but as John
said it's probably too late to do away with them.
(If recursive subscripting were done by a list instead
of by an integer or character vector there might be
less confusion and it would be more flexible.)
I don't follow this. Recursive lists are trees, and you specify a
single element of a tree by specifying a sequence of indices.
Why would
it be less confusing to give a list? What extra flexibility
could there
be? I suppose you could mix integer and character indices, but what
would be meant by x[[ list(1, list(2,3), 4) ]] ?