[R] a silly question on index of a matrix
Simon Blomberg
blomsp at ozemail.com.au
Wed Oct 26 04:19:41 CEST 2005
> ?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
More information about the R-help
mailing list