Here's one way:
H = array(c(8:5,1:4),dim=c(2,2,2))
which(H==min(H),arr.ind=TRUE)
dim1 dim2 dim3
[1,]112
which(H==max(H),arr.ind=TRUE)
dim1 dim2 dim3
[1,]111
- Phil Spector
Statis
On 10-12-27 5:26 PM, Eduardo de Oliveira Horta wrote:
Hello there
I wish to get the "coordinates" of the minimum element of an array.
For example, if the array were
H = array(c(8:5,1:4),dim=c(2,2,2))
H
, , 1
[,1] [,2]
[1,]86
[2,]75
, , 2
[,1] [,2]
[1,]1
Hello there
I wish to get the "coordinates" of the minimum element of an array.
For example, if the array were
> H = array(c(8:5,1:4),dim=c(2,2,2))
> H
, , 1
[,1] [,2]
[1,]86
[2,]75
, , 2
[,1] [,2]
[1,]13
[2,]24
then
> min(H)
[1] 1
and
> max(H)
[1]
3 matches
Mail list logo