quantify {itertools2} | R Documentation |
Returns the number of elements from an iterable object evaluate to
TRUE
.
quantify(object)
object |
an iterable object |
the number of TRUE
elements
it <- iterators::iter(c(TRUE, FALSE, TRUE))
quantify(it) # 2
set.seed(42)
x <- sample(c(TRUE, FALSE), size=10, replace=TRUE)
quantify(x) # Equivalent to sum(x)