Hi you guys, I know this might be too simple a question to post, but i searched a lot still couldn't find it. Just want to find an element in matrix and return its index , i think there should be some matrix version of "match" which only works for vector to me. thanks in advance for your help. best, tong
A matrix is a vector as well (it is stored by columns), so it has two ways of indexing [i,j] and [i]. It may be easier for you to use the latter, thus which(x == 1) returns all indexes where the matrix x is equal to 1.> -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of tong wang > Sent: Sunday, April 10, 2005 9:37 PM > To: r-help at stat.math.ethz.ch > Subject: [R] How to search an element in matrix ? > > Hi you guys, > I know this might be too simple a question to post, but > i searched a lot still couldn't find it. > Just want to find an element in matrix and return its > index , i think there should be some matrix version of > "match" which only works for vector to me. > thanks in advance for your help. > > best, > tong > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > R-project.org/posting-guide.html >