[R] finding cols and rows in a matrix

Dimitris Rizopoulos dimitris.rizopoulos at med.kuleuven.ac.be
Thu Apr 28 13:19:03 CEST 2005


check this:

mat <- matrix(rnorm(5*5), 5, 5)
mat[1, 3] <- 1; mat[4, 2] <- 2
####
which(mat==1, TRUE)
which(mat==2, TRUE)


Best,
Dimitris

----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/16/336899
Fax: +32/16/337015
Web: http://www.med.kuleuven.ac.be/biostat/
     http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm


----- Original Message ----- 
From: "javier garcia" <rn001 at cebas.csic.es>
To: <r-help at stat.math.ethz.ch>
Sent: Thursday, April 28, 2005 12:55 PM
Subject: [R] finding cols and rows in a matrix


> Hi
> Ive got big matrixes with just few non missing data, and
> would like to use or do a funtion to find the index of the row and 
> col of one
> specified value. For example I just have one "1" value in the 
> matrix, and one
> "2" value in the same matrix.
>
> Has anyone an idea about how to extract the rowindex and colindex of 
> the "1"
> value or the "2"?
>
> Thanks
>
> ______________________________________________
> 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
>




More information about the R-help mailing list