r-lib / scales

Tools for ggplot2 scales
https://scales.r-lib.org
Other
407 stars 109 forks source link

Issue with label_number(accuracy = 0.1, scale_cut = cut_short_scale()) #449

Closed rawktheuniversemon closed 4 weeks ago

rawktheuniversemon commented 1 month ago

Hi everyone, i have a list of numbers that I need to give proper formatting, but i noticed it was giving me error so I started testing out the function using random number. Results below:

Scenario that worked: label_number(accuracy = 0.1, scale_cut = cut_short_scale())(c(1998293, 19938123121, 29381123127, 3992841)) [1] "2.0M" "19.9B" "29.4B" "4.0M"

Scenario that gives error: label_number(accuracy = 0.1, scale_cut = cut_short_scale())(c(1998293, 199381, 293817, 3992841)) Error in break_suffix[bad_break][improved_break & !power10_break] <- names(lower_break[improved_break & : NAs are not allowed in subscripted assignments

I tried using multiple other cases with decimals, and the error seems to be random (i.e. sometimes it generates number whereas sometimes it shows error).

Is that something that can be resolved within the function? Or is there any limitation when using the function? Looking forward to your reply.

teunbrand commented 1 month ago

This is a known bug originally reported in https://github.com/r-lib/scales/issues/413