I got tired of writing length(which()) so I define a useful function which I source in my .Rprofile: count <- function( x ) length(which(x)) Then: count( x == 1 ) -- View this message in context: http://n4.nabble.com/counting-the-number-of-ones-in-a-vector-tp1570700p1578549.html Sent from the R help mailing list archive at Nabble.com.