How To Remove Scientific Notation in R [r no scientific notation]

When working with a large number in r, scientific notation is the default format that it will be presented in. There are, however, sometimes when you are going to want to see a large number in standard notation. Doing this type of work in r no scientific notation is possible and you have two functions that allow you to do it. It is a simple process for when you need to see numbers in such a format.

Options for Removing Scientific Notation in R

When you are looking to remove scientific format from a number, there are two functions that you can use. The first one is the options function which has two options that are relevant to the situation

  • options(scipen=999) – This turns off scientific notation.
  • options(scipen=0) – This turns scientific notation back on.

The second function is the format function, and it has the format of format(x, scientific = FALSE) where x is the variable to be displayed. The main difference between the two is that the options function turns scientific notation off for all variables, while the format function displays a specific variable. The function that you use will depend upon the situation.

How it works – removing scientific notation in R

Both functions we are using to eliminate scientific notation produce the same change in the number format. They remove the decimal point and exponent, leaving you with a whole number. They do not show any numbers after the decimal point in standard format because you are running out of digits that the system will display. However, this does not affect the use of the decimal point when using smaller numbers. This little snag simply results from the limits to what can be displayed within the r studio environment. It is important to keep in mind that the options function turns off scientific notation so that you remember to turn scientific notation back on.

Examples

Here we have two examples of turning off scientific notation with one using each of the functions. The code used in these examples is simple and straightforward.

> x = 999999999*12345
> x
[1] 1.2345e+13
> options(scipen=999)
> x
[1] 12344999987655
> options(scipen=0)
> x
[1] 1.2345e+13

In this example, we use the options function to turn on and off the scientific form of display. Remember that this approach turns off scientific format for all numeric variables. So, if you subsequently need to have the scientific format, you will need to turn it back on again using the second form of this function.

> x = 999999999*12345
> x
[1] 1.2345e+13
> format(x, scientific = FALSE)
[1] “12344999987655”
> x
[1] 1.2345e+13

In this example, we use the formatting function to convert the number into a string that is formatted in standard notation. This function has the advantage that it does not change the settings of the system making it ideal for a situation where you need to see the digits of a single number without being interfered with by scientific notation.

Applications – When to convert numbers from scientific notation to standard notation

There are many applications to being able to view a number in standard notation. When you are dealing with large numbers, sometimes it is helpful to be able to see all the available digits. One such situation is the case where you are trying to plot a group of numbers and the scientific format is getting in the way of seeing what is going on.

Displaying a large number outside of scientific format in r is a simple task, with two different methods for achieving it. Once you know how these functions work, you will easily be able to move between scientific and standard notations for displaying numbers.

Scroll to top
Privacy Policy