102

My plot is showing values on the y-axis in the form of e notation. Which command should I use to get the values in the numeric form. The values in the file used are in the numeric form? Thanks

Gaurav Chawla
  • 1,473
  • 3
  • 14
  • 19
  • 17
    What is "e notation"? Scientific notation? You can turn it off with `options(scipen = 999)` and back on again with `options(scipen = 0)` – Rich Scriven Sep 20 '14 at 06:43

2 Answers2

142

To set the use of scientific notation in your entire R session, you can use the scipen option. From the documentation (?options):

‘scipen’: integer.  A penalty to be applied when deciding to print
          numeric values in fixed or exponential notation.  Positive
          values bias towards fixed and negative towards scientific
          notation: fixed notation will be preferred unless it is more
          than ‘scipen’ digits wider.

So in essence this value determines how likely it is that scientific notation will be triggered. So to prevent scientific notation, simply use a large positive value like 999:

options(scipen=999)
Paul Hiemstra
  • 59,984
  • 12
  • 142
  • 149
103

Try format function:

> xx = 100000000000
> xx
[1] 1e+11
> format(xx, scientific=F)
[1] "100000000000"
rnso
  • 23,686
  • 25
  • 112
  • 234
  • 4
    This answer is useful if you don't want to change the global options, as in if you are doing in-line code to report results within the text portion of a .rmd file. – ESELIA Dec 30 '21 at 23:06
  • Thank you readers for 100 positive votes! – rnso Mar 31 '23 at 16:26