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

Error in break_suffix #483

Closed
mgacc0 opened this issue Dec 11, 2024 · 2 comments
Closed

Error in break_suffix #483

mgacc0 opened this issue Dec 11, 2024 · 2 comments

Comments

@mgacc0
Copy link

mgacc0 commented Dec 11, 2024

library(tidyverse)
map(
  c(-12002, 12, 1234, 123456789, 1234567890),
  ~ scales::number(
    .,
    accuracy = 0.1,
    scale_cut = scales::cut_long_scale(),
  )
)
#> [[1]]
#> [1] "-12.0K"
#> 
#> [[2]]
#> [1] "12.0"
#> 
#> [[3]]
#> [1] "1.2K"
#> 
#> [[4]]
#> [1] "123.5M"
#> 
#> [[5]]
#> [1] "1 234.6M"
scales::number(
  c(-12002, 12, 1234, 123456789, 1234567890),
  accuracy = 0.1,
  scale_cut = scales::cut_long_scale(),
)
#> Error in break_suffix[bad_break][improved_break & !power10_break] <- names(lower_break[improved_break & : NAs are not allowed in subscripted assignments
@teunbrand
Copy link
Contributor

Hi there, thanks for the report! If you download the dev version of scales, does that help the problem at all? I'm asking because a similar issue was recently fixed in the development version.

@mgacc0
Copy link
Author

mgacc0 commented Dec 11, 2024

Thanks @teunbrand.
It works correctly in the current dev version.

library(tidyverse)
packageVersion("scales")
#> [1] '1.3.0.9000'
testthat::expect_equal(
  map(
    c(-12002, 12, 1234, 123456789, 1234567890),
    ~ scales::number(
      .,
      accuracy = 0.1,
      scale_cut = scales::cut_long_scale(),
    )
  ) %>%
    unlist(),
  c("-12.0K", "12.0", "1.2K", "123.5M", "1 234.6M")
)
testthat::expect_equal(
  scales::number(
    c(-12002, 12, 1234, 123456789, 1234567890),
    accuracy = 0.1,
    scale_cut = scales::cut_long_scale()
  ),
  c("-12.0K", "12.0", "1.2K", "123.5M", "1 234.6M")
)

@mgacc0 mgacc0 closed this as completed Dec 11, 2024
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