Re: [R] a silly question on index of a matrix

From: Simon Blomberg <blomsp_at_ozemail.com.au>
Date: Wed 26 Oct 2005 - 12:19:41 EST

 > ?which
 > X <- matrix(2:10, nrow=3)
 > which(X == 10, arr.ind=TRUE)
      row col

[1,] 3 3

HTH, simon.

At 11:52 AM 26/10/2005, you wrote:
>Hi netters,
>
>This is probably a silly question,but I can't find the answer after
>searching the R-help archives online. ok, I have a matrix. I know there is
>a "10" somewhere in it. Now I want to
>know the index of the element "10" in this matrix. That is, if X[i,j]=10,
>I want to know
>i and j. Is there a R function to do this? Just like the "find" function
>in matlab.
>
>Thanks all!
>
>
>
>______________________________________________
>R-help@stat.math.ethz.ch mailing list
>https://stat.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Simon Blomberg, B.Sc.(Hons.), Ph.D, M.App.Stat. Centre for Resource and Environmental Studies The Australian National University
Canberra ACT 0200
Australia
T: +61 2 6125 7800 email: Simon.Blomberg_at_anu.edu.au F: +61 2 6125 0757
CRICOS Provider # 00120C



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Wed Oct 26 12:32:38 2005

This archive was generated by hypermail 2.1.8 : Wed 26 Oct 2005 - 15:12:38 EST