series: Find Regular Sequences Of Integers In Numeric Vector.

View source: R/series.R

seriesR Documentation

Find Regular Sequences Of Integers In Numeric Vector.

Description

Find regular sequences of integers in numeric vector v.

Usage

series(v, step = 1, minseries = 2)

Arguments

v

A numeric vector containing only whole numbers.

step

The step size and direction (distance between adjacent items) for identifying series. Note that the sign of the step matters. Use positive values for monotonically increasing series and negative values for monotonically decreasing series. Defaults to 1. Use 0 for invariant series (runs).

minseries

The minimimum series length. Defaults to 2.

Details

Takes a vector of whole numbers and returns a matrix with 3 columns: (1) integer at beginning of series, (2) index pointing to beginning of series, (3) length of series

Value

Numeric matrix with 1 row for each series, and three columns indicating:

  1. first: Integer at beginning of series.

  2. runstart: Index into v for start of series.

  3. runlength: Length of series.

Author(s)

David Braze davebraze@gmail.com


davebraze/FDButils documentation built on Feb. 24, 2023, 12:14 a.m.