clusters {intervals}R Documentation

Identify clusters in a vector of positions

Description

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.

Usage

clusters(pos, w, which = FALSE)

Arguments

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.

Details

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.

Value

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.

Note

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.


[Package intervals version 0.9.5 Index]