Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hist fails when breaks get fuzzy... #368

Closed
barryrowlingson opened this issue Mar 27, 2024 · 1 comment
Closed

hist fails when breaks get fuzzy... #368

barryrowlingson opened this issue Mar 27, 2024 · 1 comment

Comments

@barryrowlingson
Copy link

I get an error when histogramming a vector with units in very particular cases - a short vector with some "edge case" values, seems to be related to finding the breaks... I think its because its triggering "fuzz" in the breakpoints and the fuzz parameter isn't unitted:

library(units)
# two numbers near 1, two near 0...
x2u = c(rep(0.0001,2), rep(0.999,2))
# keep this for later
x2 = x2u
# add units to x2u
units(x2u) = "m"
# un-unitted version histograms okay
hist(x2)
# unitted version fails:
hist(x2u)
# Error in Ops.units(breaks, fuzz) : 
 #  both operands of the expression should be "units" objects
packageVersion("units")
[1] ‘0.8.5’

I tried passing a unitted fuzz parameter but that breaks hist.default elsewhere in a comparison between the fuzz and zero:

> hist(x2u, fuzz=fuzz)
Error in Ops.units(fuzz, 0) : 
  both operands of the expression should be "units" objects
@edzer edzer closed this as completed in 56c0b9d Mar 27, 2024
@edzer
Copy link
Member

edzer commented Mar 27, 2024

Thanks @barryrowlingson !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants