Skip to content

Filter NA in fancy_breaks() big-number abbreviation check - #1260

Open
SAY-5 wants to merge 2 commits into
r-tmap:masterfrom
SAY-5:fix-fancy-breaks-na-big-num
Open

Filter NA in fancy_breaks() big-number abbreviation check#1260
SAY-5 wants to merge 2 commits into
r-tmap:masterfrom
SAY-5:fix-fancy-breaks-na-big-num

Conversation

@SAY-5

@SAY-5 SAY-5 commented Jul 17, 2026

Copy link
Copy Markdown

Fixes #1259.

fancy_breaks() errored with "missing value where TRUE/FALSE needed" when a numeric column contained NA and the values were large enough to trigger the big.num.abbr abbreviation path (values >= 1e6). This surfaced when formatting popups in view mode, even when the NA column was not the one used for fill.

The abbreviation check all(vec_fin - floor(vec_fin/(10^o))*(10^o) < 1) returns NA when vec_fin contains NA, so if (...) throws. vec_fin was built by filtering infinite values but not NA. This filters NA too, in both places vec_fin is derived.

tmap:::fancy_breaks(c(1e6, NA, 3e6))
# before: Error: missing value where TRUE/FALSE needed
# after:  "1 mln" "NA mln" "3 mln"

Added a regression test in tests/testthat/test-fancy_breaks.R and a NEWS entry.

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
@olivroy

olivroy commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Hello @SAY-5, it seems like the new test you added fails.

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
@SAY-5

SAY-5 commented Jul 26, 2026

Copy link
Copy Markdown
Author

Good catch, the test was too strict. fancy_breaks returns a formatted vector with an align attribute from format(), so I swapped expect_identical for expect_equal(..., ignore_attr = TRUE) which only checks the values.

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

Successfully merging this pull request may close these issues.

tmap:::fancy_breaks() crashes on numeric columns with NA values when big.num.abbr path is triggered (large numbers)

2 participants