pitosalas
pitosalas

Reputation: 10862

R large numbers in output are hard to read

I am working with US population numbers and I am seeing means that look like 2001234 and sd that looks like 22211121 and it's hard to eyeball what the numbers are saying. Is there a way to ask R to change the default output format for the console or reports to be 2,001,234 etc? Or 2.001M?

I am working interactively with the R Shell so defining extra functions to do this is not so convenient. I would like to change the default.

Upvotes: 1

Views: 143

Answers (1)

mgriebe
mgriebe

Reputation: 908

As for session options, try

options(scipen = -3, digits =3)

1234567 becomes 1.2e+6 or 1.2 million

12345678 becomes 1.2e+7 or 12 million

Its not commas or M suffix, its scientific notation, which is probably easier to read than the default you are facing, and its in options.

Upvotes: 1

Related Questions