Do you actually need the intermediate result (the vector of 1's and 0's), or just the result - the total number of columns?
Is the number you're comparing to different for each column? Assuming the answers are "just the result" and "comparing to the same number" x <- matrix(c(4,5,7,2),nc=2) num <- 6 sum(apply(x<num,2,all)) -- View this message in context: http://n4.nabble.com/If-then-test-tp1322119p1330135.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ 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.