concat {iterors}R Documentation

Concatenate contents of multiple iterators into a vector.

Description

concat collects all values from an iterable object, and pastes them end to end into one vector. In other words concat is to as.list.iteror as c is to list.

Usage

concat(obj, mode = "list", n = Inf, ...)

## Default S3 method:
concat(obj, mode = "list", n = as.integer(2^31 - 1), ...)

## S3 method for class 'iteror'
concat(obj, mode = "list", n = Inf, length.out = Inf, ...)

Arguments

obj

An iteror.

mode

The mode of vector to return.

n

The maximum number of times to call nextOr(obj).

...

passed along to iteror constructor.

length.out

The target size of the output vector (after results have been pasted together). If the iteror ends (or emits n results) before emitting this many elements, the result will be shorter than length.out. If the iterator does not end early, the output will have at least length.out elements, and possibly more, as the entire last chunk will be included.

Value

a vector with mode mode.

Examples


it <- i_apply(icount(), seq_len) # [1], [1, 2], [1, 2, 3], ...
concat(it, n=4, mode="numeric")  # [1, 1, 2, 1, 2, 3, 1, 2, 3, 4]
concat(it, length.out=4, mode="numeric")  # [1, 1, 2, 1, 2, 3, 1, 2, 3, 4]

[Package iterors version 1.0 Index]