Learn R Programming

iterors (version 1.0)

quantify: Count the number of times an iterable object is TRUE

Description

Returns the number of elements from an iterable object that evaluate to TRUE.

Usage

quantify(obj, ...)

Value

the number of TRUE elements

Arguments

obj

an iterable object

...

further arguments passed to iteror.

See Also

reduce

Examples

Run this code
it <- iteror(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)

Run the code above in your browser using DataLab