[R] How to search an element in matrix ?
Vadim Ogranovich
vograno at evafunds.com
Mon Apr 11 06:51:35 CEST 2005
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
> 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