Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R displays numbers in scientific notation [duplicate]

Tags:

r

The result of function was displayed in scientific notation, I want to change it back to normal, but only for that function, I don't want to change the global setting. Can anyone help?

like image 431
ChaoYang Avatar asked Feb 02 '14 10:02

ChaoYang


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?

Data Visualization using R Programming Then, use options(scipen=999) to remove scientific notation from the plot.

How do I get rid of scientific notation in ggplot2?

Example 1: Disable Scientific Notation of ggplot2 Axis We did that by applying the scale_x_continuous function in combination with the comma function of the scales package.

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

You can do:

format(functionResult, scientific=FALSE); 

or:

as.integer(functionResult); 
like image 143
Martin Dinov Avatar answered Sep 27 '22 20:09

Martin Dinov