Description Usage Arguments Details Value Author(s) Examples
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
.
1 | sampleStep(x, step)
|
x |
Numeric or integer vector. |
step |
Numeric scalar. |
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
.
A logical vector of the same length as x
, representing the
selected subsample.
W. Huber <huber@ebi.ac.uk>
1 2 3 4 | x = sort(as.integer(runif(20)*100))
sel = sampleStep(x, step=10)
x
x[sel]
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.