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: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of tong wang > Sent: Sunday, April 10, 2005 9:37 PM > To: r-help@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@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 > ______________________________________________ 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