[R] indexing an array using an index-array, but one entry being ', '

From: Christoph Lehmann <christoph.lehmann_at_gmx.ch>
Date: Tue 19 Apr 2005 - 23:11:12 EST


Hi
I have the following array:

test <- array(c(1:16), dim = c(3,4,3))
test
## I call some enries using an index array
test.ind <- array(rbind(c(1,2,1), c(3,3,2)), dim = c(2,3)) test[test.ind]

## suppose I want all values in the 2nd row and 4th col over
## all three 3rd dimensions

test[2,4,]

how to specify a test.ind array with the last index left with ',' i.e test.ind should be evaluated as "2, 4, , " so that it can be calledlike above as test[test.ind] and the result should be [1] 11 7 3

thanks for a hint
Cheers
christoph



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue Apr 19 22:38:09 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:16 EST