keeponly: Eliminate Consecutive Extreme Values

Description Usage Arguments Value Examples

View source: R/keeponly.R

Description

Generate the index for eliminating values beyond a given maximum number of consecutive extremes allowed.

Usage

1
keeponly(x, extremes = c(0, 100), nconsec = 2)

Arguments

x

A numeric vector, with no missing values.

extremes

A numeric vector of length two giving the boundary limits for x, default c(0, 100).

nconsec

An integer scalar, the maximum number of consecutive extreme values allowed, default 2.

Value

A logical vector for selecting all elements of x without exceeding nconsec consecutive extreme values.

Examples

1
2
3
4
5
vec <- c(0, 0, 0, 4, 4, 4, 100, 100, 100, 100)
vec[keeponly(vec)]
# the original vector need not be ordered
vec <- c(100, 4, 100, 4, 0, 100, 0, 4, 0, 100)
keeponly(vec)

JVAdams/LW1949 documentation built on May 7, 2019, 10:14 a.m.