Skip to content

Commit b1df219

Browse files
committed
fix: bug with numbers between 0 and 1
1 parent 845b016 commit b1df219

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

R/utils.R

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,21 @@ AutoColor <- function(data, n, name, key) {
6666

6767
# ceiling for number bigger than zero, floor for number smaller than zero
6868
CeilingNumber <- function(x, digits = 2) {
69+
print(x)
6970
if (x == 0) {
7071
"0"
7172
} else if (abs(x) >= 10^6) {
7273
formatC(x, format = "e", digits = 2)
7374
} else if (abs(x) >= 10000) {
7475
formatC(round(x), format = "f", digits = 0)
75-
} else if ((x %% floor(x)) != 0) {
76-
formatC(x, format = "f", digits = 2)
76+
} else if (abs(x) >= 1) {
77+
if ((x %% floor(x)) != 0) {
78+
formatC(x, format = "f", digits = 2)
79+
} else {
80+
formatC(x, format = "f", digits = 0)
81+
}
7782
} else {
78-
formatC(x, format = "f", digits = 0)
83+
formatC(x, format = "f", digits = 2)
7984
}
8085
}
8186

0 commit comments

Comments
 (0)