Skip to content
Back to formatted view

Raw Message

Message-ID: <6.2.1.2.0.20051026121805.04d6d348@mail.ozemail.com.au>
Date: 2005-10-26T02:19:41Z
From: Simon Blomberg
Subject: a silly question on index of a matrix
In-Reply-To: <BAY110-F105A75B4511F38DCFDA8D5C7690@phx.gbl>

> ?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 at 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