Learn R Programming

iterors (version 1.0)

count: Consumes an iterator and computes its length

Description

Counts the number of elements in an iterator. NOTE: The iterator is consumed in the process.

Usage

count(object, ...)

Value

the number of elements in the iterator

Arguments

object

an iterable object

...

passed along to iteror constructor.

See Also

take consume as.list.iteror

Examples

Run this code
count(1:5) == length(1:5)

it <- iteror(1:5)
count(it) == length(1:5)

it2 <- i_chain(1:3, 4:5, 6)
count(it2)

it3 <- i_chain(1:3, levels(iris$Species))
count(it3)

Run the code above in your browser using DataLab