chickenNinja123
chickenNinja123

Reputation: 445

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?

Upvotes: 4

Views: 501

Answers (1)

bricx
bricx

Reputation: 663

Something like this:

as.numeric(gsub("_","", "1_000_000"))

Upvotes: 2

Related Questions