Disable Scientific Notation in R (2 Examples)
This tutorial explains how to prevent the R programming language from using scientific notation (e.g. e+10).
Example Data
numeric_value <- 2873642387462 # Example number numeric_value # Print example number # 2.873642e+12 |
numeric_value <- 2873642387462 # Example number numeric_value # Print example number # 2.873642e+12
Example 1: Modify Global Options
You can modify the global options of your R installation to not show scientific notation anymore:
options(scipen = 999) # Modify global options |
options(scipen = 999) # Modify global options
If we now print our example number, scientific notation is disabled.
numeric_value # Print example number # 2873642387462 |
numeric_value # Print example number # 2873642387462
Example 2: Use format function to Disable Scientific Notation
Another alternative is the application of the format function:
format(numeric_value, scientific = FALSE) # Apply format function # "2873642387462" |
format(numeric_value, scientific = FALSE) # Apply format function # "2873642387462"
Note that the format function converts our numeric number to a character string.