With Rle from IRanges:

sum(runValue(Rle(diff(gp))) == 1)

On Thu, Aug 5, 2010 at 4:24 AM, ALok <foralok@gmail.com> wrote:

> Hi All
> i have a object
> gp = c(1,2,3,4,21,22,23,24,38,39)
>
> and i want to count number of groups containing consecutive numbers
>
> as
>
> ans should be three as group1 (1,2,3,4), group2 (21,22,23,24) and group3
> contains (38,39)
> any suggestions
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> Bioconductor mailing list
> Bioconductor@stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/bioconductor
> Search the archives:
> http://news.gmane.org/gmane.science.biology.informatics.conductor
>

	[[alternative HTML version deleted]]

