[R] element-by-element comparison

Wendy wendy2.qiao at gmail.com
Sun Oct 30 04:51:00 CET 2011


Hi,

I have a vector and a matrix. For example,

A = [
12
3
4];

B = [
4       13
10      2
4       8];

I am comparing A to each column of B using A>B[,ii], so the expected result
is 

C = [
1    0    
0    1
0    0];

I am looking for a way to do this quickly instead of going through the for
loop, but haven't had any luck yet? Any advice is appreciated.

Thank you very much.

Wendy






--
View this message in context: http://r.789695.n4.nabble.com/element-by-element-comparison-tp3952301p3952301.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list