You can use the following methods to turn off scientific notation in R;
Method 1: Turn off scientific notation as global setting
options(scipen=999)
Method 2: Turn off scientific notation for one variable
format(x, scientific = F)
The following examples show how to use each of these methods in practice.
Method 1: Turn Off Scientific Notation as Global Setting
Suppose we perform the following multiplication in R:
#perform multiplication
x #view results
x
[1] 1.2345e+11
The output is shown in scientific notation since the number is so large.
The following code shows how to turn off scientific notation as a global setting. This means no variable in any output will be shown in scientific notation.
#turn off scientific notation for all variables options(scipen=999) #perform multiplication x #view results x [1] 123449987655
Notice that the entire number is displayed since we turned off scientific notation.
Note that the default value for scipen is 0 so you can reset this global setting by using options(scipen=0) in R:
#turn scientific notation back on
options(scipen=0)
#perform multiplication again
x #view results
x
[1] 1.2345e+11
Method 2: Turn Off Scientific Notation for One Variable
The following code shows how to turn off scientific notation for just one variable:
#perform multiplication x #display results and turn of scientific notation format(x, scientific = F) [1] "123449987655" #perform another multiplication y #view results y [1] 9.999989e+12
Notice that only the first variable is shown without scientific notation since it’s the only variable that we used the format() function on.
Additional Resources
The following tutorials show how to perform other common operations in R:
How to Round Numbers in R
How to Convert a Vector to String in R
How to Convert Data Frame Column to Vector in R
How to Convert Matrix to Vector in R