如何在 R 中停用数字的科学记数法?


我们可以使用 options(scipen=999) 来执行此操作。

示例

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

单样本 t 检验

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

95% 置信区间 −

151.3501 659.0499

样本估计 −

mean of x
405.2

此处 p 值采用科学记数法。现在我们可以按如下所示停用它 −

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

单样本 t 检验

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

95% 置信区间 −

151.3501 659.0499

样本估计 −

mean of x
405.2

如果我们想再次激活科学记数法,则可以按照如下所示操作 −

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

单样本 t 检验

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

95% 置信区间 −

151.3501 659.0499

样本估计 −

mean of x
405.2

更新日期: 06-Jul-2020

403 次查看

开启你的 职业生涯

完成课程获得认证

立即开始
广告
© . All rights reserved.