Skip to content

Detect numerical series

3 messages · syrvn, David Winsemius

#
Hello,

I am struggling with detecting successive digits in a numerical series
vector.

Here is an example:

vec <- c(1, 15, 26, 29, 30, 31, 37, 40, 41)

I want to be able to detect 29, 30, 31 and 40, 41.

Then, I would like to delete the successive digits from the vector.

1, 15, 26, 29, 37, 40


Cheers

--
View this message in context: http://r.789695.n4.nabble.com/Detect-numerical-series-tp4379088p4379088.html
Sent from the R help mailing list archive at Nabble.com.
#
On Feb 11, 2012, at 10:01 AM, syrvn wrote:

            
vec[ c(TRUE, !diff(vec) == 1) ]
#[1]  1 15 26 29 37 40
David Winsemius, MD
West Hartford, CT