sequence: Create A Vector of Sequences

Description Usage Arguments Details See Also Examples

View source: R/seq.R

Description

For each element of nvec the sequence seq_len(nvec[i]) is created. These are concatenated and the result returned.

Usage

1
sequence(nvec)

Arguments

nvec

a non-negative integer vector each element of which specifies the end point of a sequence.

Details

Earlier versions of sequence used to work for 0 or negative inputs as seq(x) == 1:x.

Note that sequence <- function(nvec) unlist(lapply(nvec, seq_len)) and it mainly exists in reverence to the very early history of R.

See Also

gl, seq, rep.

Examples

1
2
sequence(c(3, 2)) # the concatenated sequences 1:3 and 1:2.
#> [1] 1 2 3 1 2

robertzk/monadicbase documentation built on May 27, 2019, 10:35 a.m.