sampleStep: Sampling of ascending numbers to ensure minimal spacing.

Description Usage Arguments Details Value Author(s) Examples

View source: R/sampleStep.R

Description

Given a vector of ascending numbers and a step width, sample the numbers such that the difference between consecutive numbers is greater than or equal to step.

Usage

1

Arguments

x

Numeric or integer vector.

step

Numeric scalar.

Details

The simple algorithm works greedily from x[1] to x[length(x)]. First, x[1] is selected. Then, if x[i] is selected, all numbers x[j] with j>i and x[j]-x[i]<step are dropped. Then, i is set to the smallest j with x[j]-x[i]>=step.

Value

A logical vector of the same length as x, representing the selected subsample.

Author(s)

W. Huber <huber@ebi.ac.uk>

Examples

1
2
3
4
 x   = sort(as.integer(runif(20)*100))
 sel = sampleStep(x, step=10)
 x
 x[sel]

tilingArray documentation built on Nov. 8, 2020, 10:59 p.m.