如何防止R中的科学记数法?

Gau*_*wla 42 r

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

Pau*_*tra 57

要在整个R会话中设置科学记数法的使用,您可以使用该scipen选项.从文档(?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.
Run Code Online (Sandbox Code Playgroud)

所以从本质上讲,这个值决定了触发科学记数法的可能性.因此,为了防止科学记数法,只需使用大的正值,如999:

options(scipen=999)
Run Code Online (Sandbox Code Playgroud)


rns*_*nso 50

试试'格式'功能:

> xx = 100000000000
> xx
[1] 1e+11
> format(xx, scientific=F)
[1] "100000000000"
Run Code Online (Sandbox Code Playgroud)

  • 如果您不想更改全局选项,例如您正在执行内联代码来报告 .rmd 文件的文本部分中的结果,则此答案很有用。 (6认同)