[R] Efficient way to find consecutive integers in vector?

From: Johannes Graumann <johannes_graumann_at_web.de>
Date: Thu, 20 Dec 2007 22:43:05 +0100


Hi all,

Does anybody have a magic trick handy to isolate directly consecutive integers from something like this:
c(1,2,3,4,7,8,9,10,12,13)

The result should be, that groups 1-4, 7-10 and 12-13 are consecutive integers ...

Thanks for any hints, Joh



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Thu 20 Dec 2007 - 22:10:39 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 21 Dec 2007 - 00:30:20 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.