is.equidistant: Check for equidistant resolution

View source: R/helper-functions.R

is.equidistantR Documentation

Check for equidistant resolution

Description

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.

Usage

is.equidistant(x)

Arguments

x

a numeric vector.

Value

a logical value: TRUE if x has constant resolution, FALSE otherwise.

Author(s)

Andrew Dolman, Thomas Münch

Examples


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))


EarthSystemDiagnostics/prxytools documentation built on Jan. 15, 2024, 9:33 p.m.