YuLab-SMU / scatterpie

:art: scatter pie plot
https://cran.r-project.org/package=scatterpie
60 stars 15 forks source link

fixed `round_digit()` #20

Closed gwangjinkim closed 6 years ago

gwangjinkim commented 6 years ago

no infinite loop when d <= 0, while mainting the functionality for d>0.

round_digit <- function (d) {
    if (d > 1) {
        round(d)
    } else {
        round(d, -as.integer(floor(log10(abs(d)))))
    }
}

It rounds to digits=0 if d>1 and for d<1, it rounds to the first decimal different from 0. - Like the original code. But especially it doesn't end up in an endless loop for d = 0 or d < 0!

GuangchuangYu commented 6 years ago

thanks.