trim_cons_runs: Find consecuctive runs of a value in extremes of a vector

View source: R/trimConsRuns.R

trim_cons_runsR Documentation

Find consecuctive runs of a value in extremes of a vector

Description

Finds the start and end points of consecutive runs of a value in the beginning and end of a vector.

Usage

trim_cons_runs(x, val, head = 0.1, tail = 0.9, n_consec = 4)

Arguments

x

The vector

val

The value for which to find consecutive runs

head

(Proportion between 0 and 1, default = 0.1) The beginning portion of the vector in which to look for consecutive missing values

tail

(Proportion between 0 and 1, default = 0.9) The end portion of the vector in which to look for consecutive missing values

n_consec

The number of consecutive values which constitutes a 'long' run (default = 4)

Value

A list of start and end points of a vector to remove heavily weighted heads and tails containing continuous runs of a value (likely denoting missing)

Examples

## Not run: 
 x <- rbinom(100, size=1, prob=0.5)
 trunc <- trim_cons_runs(x, 1, n_consec=4)
 trunc_x <- x[trunc$start:trunc$end]

## End(Not run)

bcgov/bcgroundwater documentation built on March 18, 2024, 5:43 a.m.