Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
The post How to Turn Off Scientific Notation in R? appeared first on Data Science Tutorials
How to Turn Off Scientific Notation in R?, The following ways can be used to disable scientific notation in R. The examples that follow each method’s use in action.
Method 1: Turn Off Scientific Notation as a Global Setting
Suppose we multiply the following numbers in R:
Do the multiplication.
x <- 9999999 * 7852345
Now we can view the result
x [1] 7.852344e+13
Given the size of the output, scientific notation is used to display it.
The code that follows demonstrates how to disable scientific notation globally. This implies that no output will contain a variable expressed in scientific notation.
How to Replace String in Column using R – Data Science Tutorials
switch off all variables’ use of scientific notation
options(scipen=999)
Now let’s perform multiplication
x <- 9999999 * 7852345
View the result now
x [1] 78523442147655
Due to the fact that we disabled scientific notation, the complete number is now visible.
Because scipen has a default value of 0, you can change it by using options(scipen=0) in R:
turn scientific notation back on
options(scipen=0)
Now perform multiplication again
x <- 9999999 * 7852345
view result again
x [1] 7.852344e+13
Method 2: Turn Off Scientific Notation for One Variable
The code below demonstrates how to disable scientific notation for a single variable:
Do the multiplication.
x <- 9999999 * 7892345 x [1] 7.892344e+13
Now display the result and turn of scientific notation
Create new variables from existing variables in R – Data Science Tutorials
format(x, scientific = F) [1] "78923442107655"
Let’s perform another multiplication
y <- 9499599899 * 12599997899
Let’s view the results
y [1] 1.196949e+20
Due to the fact that we only used the format() method on the first variable, it is the only one that is displayed without scientific notation.
5 Free Books to Learn Statistics For Data Science – Data Science Tutorials
The post How to Turn Off Scientific Notation in R? appeared first on Data Science Tutorials
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.