View source: R/helper-functions.R
is.equidistant | R Documentation |
This function checks whether a numeric vector (e.g. a depth vector or from a
time series) has equidistant increments, i.e. a constant resolution. This
check includes a numerical tolerance that accounts for the machine
respresentation of floating-point numbers, which circumvents the problems
popular methods of checking equidistance have which use, e.g., sd()
or
unique()
on the difference vector of x
.
is.equidistant(x)
x |
a numeric vector. |
a logical value: TRUE
if x
has constant resolution,
FALSE
otherwise.
Andrew Dolman, Thomas Münch
is.equidistant(1 : 10)
is.equidistant(c(2.5, 5, 7.5, 10, 12.5))
is.equidistant(x <- seq(0, 12, 0.1)) # compare this to sd(diff(x)) == 0!
is.equidistant(c(1 : 10, 18))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.