resolution(x, zero = TRUE)
The resolution is is the smallest non-zero distance between adjacent values. If there is only one unique value, then the resolution is defined to be one.
If x is an integer vector, then it is assumed to represent a discrete variable, and the resolution is 1.
resolution(1:10)[1] 1resolution((1:10) - 0.5)[1] 0.5resolution((1:10) - 0.5, FALSE)[1] 1resolution(c(1,2, 10, 20, 50))[1] 1resolution(as.integer(c(1, 10, 20, 50))) # Returns 1[1] 1