[R] Index of item in matrix
Roger Bivand
Roger.Bivand at nhh.no
Thu Apr 3 08:38:04 CEST 2003
On Wed, 2 Apr 2003, John Janmaat wrote:
> Hello All,
>
> Is there a fast way to find the index(row and column) of a point in a
> matrix?
> x <- matrix(rnorm(25), 5, 5)
> which(x < -1, arr.ind=TRUE)
row col
[1,] 1 1
[2,] 2 1
[3,] 2 2
[4,] 5 2
[5,] 1 3
[6,] 2 4
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Breiviksveien 40, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93
e-mail: Roger.Bivand at nhh.no
More information about the R-help
mailing list