seqToIntervals {R.utils}R Documentation

Gets all contigous intervals of a vector of indices

Description

Gets all contigous intervals of a vector of indices.

Usage

## Default S3 method:
seqToIntervals(idx, ...)

Arguments

idx A vector of integer indices.
... Not used.

Author(s)

Henrik Bengtsson (http://www.braju.com/R/)

See Also

*intervalsToSeq().

Examples

x <- 1:10
y <- seqToIntervals(x)
print(y)  # [1 10]

x <- c(1:10, 15:18, 20)
y <- seqToIntervals(x)
print(y)  # [1 10; 15 18; 20 20]

z <- intervalsToSeq(y)
print(z)
stopifnot(all.equal(x,z))

[Package R.utils version 1.1.1 Index]