Skip to content

number(accuracy = NULL) heuristic can fail #251

@davidchall

Description

@davidchall

The label_number family of functions have a default value of accuracy = NULL. According to the documentation, this:

uses a heuristic that should ensure breaks have the minimum number of digits needed to show the difference between adjacent values.

Unfortunately, it seems this heuristic can fail under certain conditions. Here's an example:

> scales::comma(c(Inf, 1, Inf, 0))
Error in if (smallest_diff < sqrt(.Machine$double.eps)) { : 
  missing value where TRUE/FALSE needed

It looks like the problem stems from the underlying scales::number function:

> scales::number(c(Inf, 1, Inf, 0))
Error in if (smallest_diff < sqrt(.Machine$double.eps)) { : 
  missing value where TRUE/FALSE needed

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions