Last data update: 2014.03.03
|
R: Find contiguous ranges of a given value within a sequence
Find contiguous ranges of a given value within a sequence
Description
Identify the index ranges for a given value in a sequence and return
the minimum and maximum values of the ranges.
Arguments
target |
A value to find in x
|
x |
A vector
|
Value
A data.frame where each row specifies the end points
of a contiguous range that contains the target value
Usage
range_for(target, x)
Author(s)
Brian Lee Yung Rowe
Examples
# Find all contiguous ranges containing 2
x <- sample(c(1,2,2,2,3,4), 20, replace=TRUE)
range_for(2,x)
Results
|