range_merge: merge a set of numbers into a range.

Description Usage Arguments Note Author(s) Examples

Description

Useful for working out what is the minimal information to describe a series of numbers

Usage

1
range_merge(x, gaplength = 0)

Arguments

x

a numeric vector

gaplength

allow a gap within a run. default=0

Note

This is almost certainly replaceble using code from IRanges package, and Rle obects.

Author(s)

Mark Cowley

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
x <- c(1, 2, 3, 4, 5, 9)
range_merge(x)
#   from to
# 1    1  5
# 2    9  9
range_merge(x, gaplength=3)
#   from to
# 1    1  9
range_merge(x, gaplength=2)
#   from to
# 1    1  5
# 2    9  9

drmjc/mjcbase documentation built on May 15, 2019, 2:27 p.m.