How to prevent scientific notation in R?

R

R Problem Overview


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

R Solutions


Solution 1 - R

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)

Solution 2 - R

Try format function:

> xx = 100000000000
> xx
[1] 1e+11
> format(xx, scientific=F)
[1] "100000000000"

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionGaurav ChawlaView Question on Stackoverflow
Solution 1 - RPaul HiemstraView Answer on Stackoverflow
Solution 2 - RrnsoView Answer on Stackoverflow