scales icon indicating copy to clipboard operation
scales copied to clipboard

`label_number` error when including `scale_cut` argument

Open cb12991 opened this issue 1 year ago • 11 comments

Error occurs when supplying scale_cut argument && number input actually cut (i.e., 1,000 -> 1K).

For example, no error thrown when number input does not need cutting:

scales::label_number(scale_cut = scales::cut_short_scale())(mtcars$mpg) 
#>  [1] "21.0" "21.0" "22.8" "21.4" "18.7" "18.1" "14.3" "24.4" "22.8" "19.2"
#> [11] "17.8" "16.4" "17.3" "15.2" "10.4" "10.4" "14.7" "32.4" "30.4" "33.9"
#> [21] "21.5" "15.5" "15.2" "13.3" "19.2" "27.3" "26.0" "30.4" "15.8" "19.7"
#> [31] "15.0" "21.4"

Error thrown when number input requires cutting:

scales::label_number(scale_cut = scales::cut_short_scale())(mtcars$mpg^2)
#> Error in break_suffix[bad_break][improved_break & !power10_break] <- names(lower_break[improved_break & : NAs are not allowed in subscripted assignments

Created on 2023-11-29 with reprex v2.0.2

cb12991 avatar Nov 29 '23 16:11 cb12991