Description Usage Arguments Examples
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.
1 | contiguous.stretch(data, position, value, equality)
|
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. |
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
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.