1

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.

pitosalas
  • 10,286
  • 12
  • 72
  • 120
  • You could write your own `print()` method and stick it in your `.Rprofile` – Rich Scriven Jun 09 '16 at 20:59
  • [This post](http://stackoverflow.com/questions/3838774/comma-separator-for-numbers-in-r) doesn't help? – zx8754 Jun 09 '16 at 20:59
  • NB: I am a newbie still going through tutorials etc. I was looking for a way that would set a session default so that whenever I get output to the console it looks legible. In both your notes it seems to require defining my own function. Although I didn't know about .Rprofile. Will check that out. – pitosalas Jun 09 '16 at 21:02

1 Answers1

1

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.

mgriebe
  • 908
  • 5
  • 8