get_sequence: Get start and end indices of sequences of patterns

View source: R/get_sequence.R

get_sequenceR Documentation

Get start and end indices of sequences of patterns

Description

Given a vector x and a pattern, the function returns the start and end indices of the sequences with at least minsize repetitions of the pattern.

Usage

get_sequence(x, pattern, minsize = 2L)

Arguments

x

a vector

pattern

the pattern to look for

minsize

the minimum length of the repeating pattern. Must be higher than 2 for single pattern.

Value

Returns a matrix with the range of the sequence. Each row representes a sequence.

Author(s)

Jakob Gepp, Robin Kraft

Examples

get_sequence(x = c(0,1,1,0,0,0,0,3,0,0,1,0,423,0,0,0,0,0,1,0),
             pattern = 0,
             minsize = 4)

#      min max
# [1,]   4   7
# [2,]  14  18


STATWORX/helfRlein documentation built on Feb. 12, 2024, 2:21 a.m.