Skip to content

basic array question

3 messages · Tim Alcon, Uwe Ligges, PIKAL Petr

#
I have a large array and would like to extract from it the row and 
column indices just of values for which a particular boolean condition 
is true.  I assume there's a simple way to do this, but I haven't 
figured it out yet.  Any help would be appreciated.

Tim
#
Tim Alcon wrote:
Do you mean a matrix, i.e. exactly 2 dimensions?
Example:


  X <- matrix(1:9, 3)
  col(X)[X == 4]
  row(X)[X == 4]

Uwe Ligges
#
Hi
On 2 Jun 2006 at 10:26, Uwe Ligges wrote:
Date sent:      	Fri, 02 Jun 2006 10:26:44 +0200
From:           	Uwe Ligges <ligges at statistik.uni-dortmund.de>
Organization:   	Fachbereich Statistik, Universitaet Dortmund
To:             	Tim Alcon <talcon at iastate.edu>
Copies to:      	r-help at stat.math.ethz.ch
Subject:        	Re: [R] basic array question
or
row col
[1,]   1   2
which works on higher dim arrays too
, , 1

     [,1] [,2]
[1,]    1    4
[2,]    2    5
[3,]    3    6

, , 2

     [,1] [,2]
[1,]    7   10
[2,]    8   11
[3,]    9   12
dim1 dim2 dim3
[1,]    3    2    1
HTH
Petr
Petr Pikal
petr.pikal at precheza.cz