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

add functionality for big numbers #8

Open
mgacc0 opened this issue Aug 3, 2016 · 3 comments
Open

add functionality for big numbers #8

mgacc0 opened this issue Aug 3, 2016 · 3 comments
Labels
feature a feature request or enhancement

Comments

@mgacc0
Copy link

mgacc0 commented Aug 3, 2016

Would you consider to add some functionality to prettyunits
like mentioned here https://bugs.r-project.org/bugzilla/show_bug.cgi?id=16982

#Abbreviate some big numbers using a suffix "k", "M":
abbreviate_num <- function (i) {
    n <- floor(log(i, 1000))
    n <- ifelse(n>2, 2, n)
    paste0(round(i/(1000^n), 2), c("", "k", "M")[n+1])
}
abbreviate_num(222)
[1] "222"
abbreviate_num(1422)
[1] "1.42k"
abbreviate_num(14223)
[1] "14.22k"
abbreviate_num(14223323)
[1] "14.22M"
@gaborcsardi
Copy link
Member

This is almost the same as the existing pretty_bytes function, so it could use the same implementation. It seems that only the suffix is different, e.g. M instead of MB.

@mgacc0
Copy link
Author

mgacc0 commented Aug 3, 2016

And also with a difference in the base (of the power): 1000!=1024

On August 3, 2016 2:12:26 PM GMT+02:00, "Gábor Csárdi" notifications@github.com wrote:

This is almost the same as the existing pretty_bytes function, so it
could use the same implementation. It seems that only the suffix is
different, e.g. M instead of MB.


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub:
#8 (comment)

@gaborcsardi
Copy link
Member

@mgacc0 pretty_bytes actually uses 1000. See https://en.wikipedia.org/wiki/Kilobyte

@gaborcsardi gaborcsardi added enhancement feature a feature request or enhancement and removed enhancement labels Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants