Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a digit separator in R like using underscore in Python?

In Python there is a way to make large numerals more readable using the underscore, e.g. 1000000 == 1_000_000, as discussed several times here. However, is there something similar in R?

Googling it just leads me to how to format the variable as a string using format and formatC. I already tried 1_000, 1 000, 1'000 and 1,000 but they only produce error messages. Is there really no workaround?

like image 531
chickenNinja123 Avatar asked Oct 16 '25 20:10

chickenNinja123


1 Answers

Something like this:

as.numeric(gsub("_","", "1_000_000"))
like image 78
bricx Avatar answered Oct 18 '25 11:10

bricx



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!