contiguous.stretch: finds the adjacent locations equal to given one

Description Usage Arguments Examples

View source: R/utils.R

Description

given a vector of values and a position, it returns a boolean vector of the elements satisfying the condition. the condition is either equality or disequality with the given value around the positon.

Usage

1
contiguous.stretch(data, position, value, equality)

Arguments

data

a vector of whatever type.

position

numeric; the position within the input data.

value

same type as in 'data'; optional, defaults to 'data[position]'; the expected value at position.

equality

boolean; optional, defaults to TRUE; whether we are looking for the stretch of data that is equal to value or different.

Examples

1
2
3
4
5
data <- c(1,1,1,2,2,2,3,3,2,2,2,2,2,3,3,1,1,1,1,1)
which(contiguous.stretch(data, 1)) # gives 1, 2, 3
which(contiguous.stretch(data, 2)) # gives 1, 2, 3
which(contiguous.stretch(data, 5)) # gives 4, 5, 6
contiguous.stretch(data, 5, 1) # gives all FALSE

delftfews documentation built on May 2, 2019, 4:48 p.m.