iseq: Iterators for sequence generation

Description Usage Arguments Details Value Examples

View source: R/iseq.r

Description

Constructs iterators that generate regular sequences that follow the seq family.

Usage

1
2
3
4
5
6
iseq(from = 1, to = 1, by = (to - from)/(length_out - 1),
  length_out = NULL, along_with = NULL)

iseq_len(length_out = NULL)

iseq_along(along_with = NULL)

Arguments

from

the starting value of the sequence

to

the end value of the sequence

by

increment of the sequence.

length_out

desired length of the sequence. A non-negative number, which for seq will be rounded up if fractional.

along_with

the length of the sequence will match the length of this argument

Details

The iseq function generates a sequence of values beginning with from and ending with to. The sequence of values between are determined by the by, length_out, and along_with arguments. The by argument determines the step size of the sequence, whereas length_out and along_with determine the length of the sequence. If by is not given, then it is determined by either length_out or along_with. By default, neither are given, in which case by is set to 1 or -1, depending on whether to > from.

seq_along and seq_len return an iterator, which generates a sequence of integers, beginning with 1 and proceeding to an ending value

Value

sequence's iterator

Examples

1
2
3
4
5
6
7
8
it <- iseq(from=2, to=5)
unlist(as.list(it)) == 2:5

it2 <- iseq_len(4)
unlist(as.list(it2)) == 1:4

it3 <- iseq_along(iris)
unlist(as.list(it3)) == 1:length(iris)

itertools2 documentation built on May 30, 2017, 7:17 a.m.