Description Usage Arguments Details Value Note Author(s) References See Also Examples
For each value in a numeric vector, return the closest match from a vector of candidate values.
1 |
x |
numeric |
rule |
a vector of (finite numeric) candidates, or a single value giving candidate interval on the real number line |
left |
whether to return the lesser of two equidistant candidates |
... |
ignored |
If rule
is scalar, it must be positive; a rule will be constructed
as a sequence of rule-spaced values that includes zero and includes values at least as
extreme as the extremes of x
. In some sense, this function is the complement
to cut
: whereas in cut
one specifies the "breaks", with snap
one
specifies a set of "attractors" (breaks are the implied midpoints); both functions map their
primary argument to a (possibly) smaller set of values.
numeric
If length of x is zero, it is returned unmodified. If length of rule is zero, value is all NA.
Tim Bergsma
http://metrumrg.googlecode.com
findInterval
cut
1 2 3 4 5 6 7 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.