Hello, I have a matrix m and I want to know how often does 1 (or !0) simultanously appear in A and REF, B and REF, C and REF.
So actually I wish to automate following expression: > length (which (m[,1]!=0&m[,4]!=0)) [1] 2 > length (which (m[,2]!=0&m[,4]!=0)) [1] 1 Thanks Hermann > m A B C REF r1 1 0 0 1 r2 1 1 0 0 r3 0 0 1 1 r4 0 0 1 1 r5 1 1 0 1 > dput (m) structure(c(1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1), .Dim = c(5L, 4L), .Dimnames = list(c("r1", "r2", "r3", "r4", "r5"), c("A", "B", "C", "REF"))) [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.