I\'m getting a warning message I don\'t understand for simple bar charts in ggplot2
> df <- data.frame(X = 127:131, Y = rnorm(5))
> df
X Y
Setting options(warn = 2, error = recover), and rerunning the code lets us find the problem.
Inside the collide
function (number 16 in the call stack), there is this piece of code:
if (!zero_range(range(widths))) {
warning(name, " requires constant width: output may be incorrect",
call. = FALSE)
}
Floating point rounding errors mean that widths
takes slightly different values.
format(widths, digits = 22)
# [1] "0.9000000000000056843419" "0.8999999999999914734872" "0.8999999999999772626325"
The tolerance for checking that the numbers are the same is too strict: about 2.2e-14.
args(zero_range)
# function (x, tol = .Machine$double.eps * 100)
# NULL
.Machine$double.eps * 100
# [1] 2.220446e-14
So the warning is erroneous; don't worry about it.