Skip to content

Commit

Permalink
fixed a bug with negative units
Browse files Browse the repository at this point in the history
  • Loading branch information
jokergoo committed Dec 8, 2022
1 parent 46d41b9 commit 7f95b79
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ CHANGES in VERSION 2.15.1

* `Legend()`: allows `NA` in `pch`.
* `SingleAnnotation()`: correctly calculate the max width/height of a vector of texts.
* `to_unit()`: fixed a bug when the unit is negative.

=======================

Expand Down
2 changes: 1 addition & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -1020,7 +1020,7 @@ to_unit_str = function(unit) {

to_unit = function(str) {
d = gsub("[^\\d]+$", "", str, perl = TRUE)
u = gsub("[\\d.]", "", str, perl = TRUE)
u = gsub("^.*[\\d.]", "", str, perl = TRUE)
unit(as.numeric(d), u)
}

Expand Down

0 comments on commit 7f95b79

Please sign in to comment.