如何预防科学记数法?

我的图以 e 符号的形式显示 y 轴上的值。我应该使用哪个命令来获取数值形式的值。使用的文件中的值是数字形式的吗? 谢谢

208676 次浏览

Try format function:

> xx = 100000000000
> xx
[1] 1e+11
> format(xx, scientific=F)
[1] "100000000000"

To set the use of scientific notation in your entire R session, you can use the scipen option. From the documentation (?options):

‘scipen’: integer.  A penalty to be applied when deciding to print
numeric values in fixed or exponential notation.  Positive
values bias towards fixed and negative towards scientific
notation: fixed notation will be preferred unless it is more
than ‘scipen’ digits wider.

So in essence this value determines how likely it is that scientific notation will be triggered. So to prevent scientific notation, simply use a large positive value like 999:

options(scipen=999)