Try this... Perhaps this will help you do what you want. The key idea is 
to use which() with option arr.ind = TRUE.

arr <- array(rnorm(27),c(3,3,3))
dimarr <- dim(arr)
tmparr <- array(1:prod(dimarr),dimarr)
sapply(c(3),function(x,tmparr) which(tmparr==x,T),tmparr=tmparr)
sapply(c(3,17,13,5),function(x,tmparr) which(tmparr==x,T),tmparr=tmparr)

Jerome

On July 30, 2003 01:42 pm, Buchsbaum, Brad (NIH/NIMH) wrote:
> Hi,
>
> Suppose I have a multidimensional array:
>
> tmp <- array(1:8, c(2,2,2))
>
> is there a function out there that, given a one-dimensional array index,
> will
> return the separate indices for each array dimension?
>
> for instance, tmp[8] is equivalent to tmp[2,2,2]. I'd like to derive the
> vector (2,2,2)
> from the index 8.
>
> thanks,
>
> Brad Buchsbaum
>
> ______________________________________________
> [EMAIL PROTECTED] mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

Reply via email to