Skip to content

hist fails when breaks get fuzzy... #368

@barryrowlingson

Description

@barryrowlingson

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions