clusters {intervals} | R Documentation |
This function uses tools in the intervals package to quickly identify clusters – collections of positions each of which is no more than a given distance from at least one other member of the cluster – in a vector of positions.
clusters(pos, w, which = FALSE)
pos |
A numeric vector. |
w |
Maximum permitted distance between a cluster member and at least one other member. |
which |
Should indices into the pos vector be returned instead of
actual positions? Default is to return actual positions, i.e.,
values from the pos vector.
|
A cluster is defined to be a set of two or more components of
pos
, each of which has at least one other cluster member within
distance w
.
A list whose components are the clusters. Each component is thus a
vector of positions, or, if which = TRUE
, a vector of
indices into the pos
vector.
Implementation is by one call to reduce
and one call to
interval_overlap
, and the function, while useful, is
included to illustrate the utility of the core functions in the
intervals package.