resolution: Compute the "resolution" of a numeric vector

View source: R/utilities-resolution.R

resolutionR Documentation

Compute the "resolution" of a numeric vector

Description

The resolution 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.

Usage

resolution(x, zero = TRUE, discrete = FALSE)

Arguments

x

numeric vector

zero

should a zero value be automatically included in the computation of resolution

discrete

should vectors mapped with a discrete scale be treated as having a resolution of 1?

Examples

resolution(1:10)
resolution((1:10) - 0.5)
resolution((1:10) - 0.5, FALSE)

# Note the difference between numeric and integer vectors
resolution(c(2, 10, 20, 50))
resolution(c(2L, 10L, 20L, 50L))

hadley/ggplot2 documentation built on April 24, 2024, 12:16 a.m.