[R] comparing row by row in matrix

Petra Steiner steinep at uni-muenster.de
Tue Mar 26 20:07:50 CET 2002


Hello,

and thanks for the two responses to my questions on binary matrixes, which
showed me that the functions I needed do not exist.

To get a distance matrix with the Russell-Rao-coefficient, I first have to
compare each row of a binary matrix with each row and count how many
elements are
a. equal
and
b. 1.

by
f <- function(x,y) (sum(x == 1& y == x))

Now how can I iterate this over a matrix without a loop? I think apply etc.
will not work in this case.

Thanks for any help.

Regards,
Petra

-
---------------------------------------------------
Petra Steiner
Arbeitsbereich Linguistik
Universitaet Muenster
Huefferstrasse 27
48149  Muenster

Tel: 0251 / 83 39442
petra at marley.uni-muenster.de
http://santana.uni-muenster.de/~petra/





-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list