[R] Detect numerical series

2012-02-11 Thread syrvn
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

Re: [R] Detect numerical series

2012-02-11 Thread David Winsemius
On Feb 11, 2012, at 10:01 AM, syrvn wrote: 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

Re: [R] Detect numerical series

2012-02-11 Thread syrvn
That's great code. Thanks a lot! -- View this message in context: http://r.789695.n4.nabble.com/Detect-numerical-series-tp4379088p4379133.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list

Re: [R] Detect numerical series

2012-02-11 Thread Carl Witthoft
This was actually answered a couple times in StackOverflow. Someone and I indpendently wrote up the following function, stolen directly from the source for rle(). # extended version of rle to find all sorts of sequences # if incr=0, this is rle seqle- function (x,incr=1) { if