Was it helpful?

Question

How to deactivate scientific notation of numbers in R?

R ProgrammingServer Side ProgrammingProgramming

We can use options(scipen=999) to do this.

Example

> x <-c(253,254,36,874,351,651,245,274,19,1095)
> t.test(x,mu=2000)

One Sample t-test

data: x
t = -14.212, df = 9, p-value = 1.801e-07
alternative hypothesis: true mean is not equal to 2000

95 percent confidence interval −

151.3501 659.0499

sample estimates −

mean of x
405.2

Here p-value is in scientific notation. Now we can deactivate it as follows −

> options(scipen=999)
> t.test(x,mu=2000)

One Sample t-test

data: x
t = -14.212, df = 9, p-value = 0.0000001801
alternative hypothesis: true mean is not equal to 2000

95 percent confidence interval −

151.3501 659.0499

sample estimates −

mean of x
405.2

If we want to activate scientific notation again then it be done as shown below −

> options(scipen=0)
> t.test(x,mu=2000)

One Sample t-test

data: x
t = -14.212, df = 9, p-value = 1.801e-07
alternative hypothesis: true mean is not equal to 2000

95 percent confidence interval −

151.3501 659.0499

sample estimates −

mean of x
405.2
raja
Published on 06-Jul-2020 17:52:57
Advertisements
Was it helpful?
Not affiliated with Tutorialspoint
scroll top