[R] indexing an array

siim@obs.ee siim at obs.ee
Thu Sep 20 09:57:15 CEST 2001


Dear everybody,

I have a following problem.  I have a 3D array

lambda <- array( dim=c(N,M,M-1))

where I have to extract the elements as follows:

lambda[ 1, state[1], 1]
lambda[ 1, state[1], 2]
...
lambda[ 1, state[1], M-1]
lambda[ 2, state[2], 1]
...
lambda[ 2, state[2], M-1]
...
lambda[ N, state[N], M-1]

i.e. the result should be a 2D array, where the second index follows the
first one and the third is free (lambda[i,state[i],]).  The process is
to be repeated so I do not want to write a cycle.

Any suggestions?

Thanks in advance,

Ott Toomet



-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list