sum() looks faster to me tmp <- as.logical(rbinom(100,1,.5))
> system.time(for (i in 1:10000) length(tmp[tmp])) [1] 0.09 0.00 0.09 NA NA > system.time(for (i in 1:10000) sum(tmp)) [1] 0.03 0.00 0.03 NA NA I am running on Windows XP > Sys.getenv()[20] PROCESSOR_IDENTIFIER "x86 Family 15 Model 2 Stepping 4, GenuineIntel" > ______________________________________________ R-help@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