How to remove Scientific Notation in R

How to remove Scientific Notation in R, To disable scientific notation in R, use the following methods:

The examples below demonstrate how to utilize each of these strategies in practice.

Method 1: As a global setting, disable scientific notation

options(scipen=999)

Assume we use R to execute the following multiplication.

Stock Market Predictions Next Week » finnstats

multiply the numbers

x <- 9989599999 * 59785645
x
[1] 5.972347e+17

Because the number is so large, the output is given in scientific notation.

The code below demonstrates how to disable scientific notation in a global setting. This means that no variable will be displayed in scientific notation in any output.

For all variables, turn off scientific notation.

options(scipen=999)
x <- 9989599999 * 59785645
x
[1] 597234679232214400

Since we switched off scientific notation, the complete number is displayed.

Because the default value for scipen is 0, you can use options(scipen=0) in R to reset this global setting.

Now return to scientific notation

options(scipen=0)
x <- 9989599999 * 59785645
x
1] 5.972347e+17

Method 2: How to remove Scientific Notation in R for one variable

format(x, scientific = F)

The code below demonstrates how to disable scientific notation for a single variable.

Best Course For Data Analytics Free » finnstats

Now we can perform multiplication

x <- 9989599999 * 59785645
x
1] 5.972347e+17

show the results and change the scientific notation

format(x, scientific = F)
[1] "597234679232214400"

The variable is shown without scientific notation because it was the variable on which the format() function was called.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

twelve − 4 =