runs_in_sequence: Determine Runs in a Sequence

View source: R/S03_Utilities.R

runs_in_sequenceR Documentation

Determine Runs in a Sequence

Description

Given a sequence of values of which a subset are dubbed 'hits', determine the number of runs of hits and the start and end of each run of hits.

Usage

runs_in_sequence(x, codes_for_hit = 1)

Arguments

x

A vector of values.

codes_for_run

A vector of the values in x indicating a hit.

Value

A list with a) the total number of runs, and b) a matrix with a column for the start position of each run and a column for the end position of each run.

Examples

# Generate a sequence of zeros and ones
x <- rbinom( 10, 1, .5 )
print(x)
# Determine runs of ones
runs_in_sequence( x )


rettopnivek/arfpam documentation built on Oct. 20, 2024, 7:24 p.m.