Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions R/utilities-resolution.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
#' 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.
#' discrete variable, and the resolution is 1. If the differences are all smaller
#' than the tolerance, set resolution to 1.
#'
#' @param x numeric vector
#' @param zero should a zero value be automatically included in the
Expand Down Expand Up @@ -33,5 +34,7 @@ resolution <- function(x, zero = TRUE, discrete = FALSE) {
}
d <- diff(sort(x))
tolerance <- sqrt(.Machine$double.eps)
min(d[d > tolerance])

min(d[d > tolerance], 1)

}
3 changes: 2 additions & 1 deletion man/resolution.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading