Skip to content
Prev 132671 / 398506 Next

Finding overlaps in vector

If you want indexes, i.e. 1, 2, 3, ... instead of the values in v you
can still use split -- just split on seq_along(v) instead of v (or if
v had names you might want to split along names(v)):

split(seq_along(v), ct)

and if you only want to retain groups with 2+ elements then
you can just Filter then out:

twoplus <- function(x) length(x) >= 2
Filter(twoplus, split(seq_along(v), ct))
On Dec 22, 2007 5:12 AM, Johannes Graumann <johannes_graumann at web.de> wrote: