【问题标题】:Format scientific notation in R [duplicate]在R中格式化科学记数法[重复]
【发布时间】:2019-03-25 18:25:40
【问题描述】:

我有一个显示为

的号码
a <- 1.34467773e-5. 

我想把它格式化成

a <- 1.34e-5. 

我该怎么做?

谢谢。

【问题讨论】:

  • options(digits=3)

标签: r numbers format


【解决方案1】:
formatC(a, format = "e", digits = 2)

【讨论】:

  • 问题中不清楚期望的输出是numeric还是character,这是后者。 G5W 的评论是前者。
【解决方案2】:

您也可以使用函数sprintf。例如:

sprintf("%.1e", 0.00008765)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-15
    • 2013-04-27
    • 2022-01-15
    • 2013-06-27
    • 1970-01-01
    • 2021-05-01
    相关资源
    最近更新 更多