[R] Extracting Hash via Vector
Wacek Kusnierczyk
Waclaw.Marcin.Kusnierczyk at idi.ntnu.no
Tue Jan 13 13:00:44 CET 2009
Wacek Kusnierczyk wrote:
>
> x[[q]] is equivalent to x[['some']][['more']][['not_there']]. since
> x[['some']] is an atomic integer vector, it won't collaborate with
> [['more']]
>
æsj, one more lousy statement. x[['some']] is an atomic *double* vector
*with no element named 'more'*, hence x[['some']][['more']] won't work.
anyway, the point is that 'some' is used as an index on the first
element of x, rather than on x itself -- because of the recursive indexing.
one might argue that recursive indexing should be done explicitly, by
repeating the use of [[, and that [[q]] performing recursive indexing
when length(q) > 1 is yet another 'optimization' in r that easily leads
to confusion. it is not unreasonable to think that x[[q]] might return
a concatenation of the respective elements of x:
x = as.list(1:2)
x[1]
# [[1]] 1
x[1:2]
# [[1]] 1
# [[2]] 2
x[[1]]
# 1
x[[1:2]]
# 1 2 (but it will rather fail)
vQ
More information about the R-help
mailing list