cluster1d: Group one-dimensional data into clusters of contiguous points

Description Usage Arguments Value Examples

Description

Group one-dimensional data into clusters of contiguous points

Usage

1
cluster1d(x, gap, frac = NULL)

Arguments

x

Numeric vector of points to be grouped into clusters

gap

Size of gap that separates two neighboring clusters

frac

Size of gap that separates two neighboring clusters expressed as a fraction of the range of ‘x’

Value

Returns an integer vector that is aligned with ‘x’ and contains the cluster for the associated element in ‘x’. NA values in ‘x’ will have NA values in the resulting vector.

Examples

1
2
3
x <- c(9, 12, 3, 4, 17, 10, 12, NA, 6, 1)
cluster1d(x, gap = 3)
cluster1d(x, frac = .15)

cbaumbach/miscFun documentation built on May 13, 2019, 1:48 p.m.