On Wed, Jul 8, 2009 at 9:40 AM, Henrique Dallazuanna <wwwhsd@gmail.com>wrote:

> Its because '[[' accept only element, so you need use '[':
>
> q[crossRsorted[,1]]
>

This appears to be doing something different. For instance, my 'q' has 165
components, but what you suggest has 15750:
> length(q)
[1] 165
> length(q[ crossRsorted[,1] ])
[1] 15750

hardly what I want.

Meanwhile, it looks as though [[ ]] does not vectorize its arguments, it
curries them!

Note that:

> q[[c(105,104)]]
Error in q[[c(105, 104)]] : subscript out of bounds

gives the same error as:

> q[[105]][[104]]
Error in q[[105]][[104]] : subscript out of bounds

Very mysterious, though, in all fairness, explained in help("[[") where it
says:

     '[[' can be applied recursively to lists, so that if the single
     index 'i' is a vector of length 'p', 'alist[[i]]' is equivalent to
     'alist[[i1]]...[[ip]]' providing all but the final indexing
     results in a list.

which leads to square one: how to express "select all r[i] where q[[i]]
fulfills some predicate?"

 - Godmar

	[[alternative HTML version deleted]]


