Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent scientific notation in R? [duplicate]

Tags:

r

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

like image 639
Gaurav Chawla Avatar asked Sep 20 '14 06:09

Gaurav Chawla


People also ask

How do you stop R from showing scientific notation?

Targeted. If you want to avoid scientific notation for a given number or a series of numbers, you can use the format() function by passing scientific = FALSE as an argument.

How do I get rid of E+ in R?

In order to eliminate the exponential notation of the integer, we can use the global setting using options() method, by setting the scipen argument, that is options(scipen = n).

What is Scipen in R?

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.


1 Answers

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) 
like image 83
Paul Hiemstra Avatar answered Oct 10 '22 01:10

Paul Hiemstra