【问题标题】:rpart.plot remove scientific notationrpart.plot 删除科学记数法
【发布时间】:2017-07-28 04:04:36
【问题描述】:
> fit <- rpart(price ~ carat + cut + clarity, diamonds_train, method = "anova")

> rpart.plot(fit, type = 4, extra = 101)

我试过options(scipen=10),但没用。如何删除科学记数法?

【问题讨论】:

  • 从 rpart.plot 的文档中引用数字参数:显示数字中的有效位数。默认 2。如果为 0,则使用 getOption("digits")。详细信息:从 0.001 到 9999 的数字打印不带指数(位数实际上只是一个建议,详见格式)。超出该范围的数字以“工程”指数(3 的倍数)打印。

标签: r rpart


【解决方案1】:

digits 参数使用负值。 rpart.plot 帮助页面说如果digits 为负数,rpart.plot 使用标准R format 函数(绝对值为digits):

library(ggplot2)
data(diamonds)
library(rpart.plot)
fit <- rpart(price ~ carat + cut + clarity, diamonds, method = "anova")
rpart.plot(fit, type = 4, extra = 101, digits=-3)

这需要rpart.plot 2.1.2 或更高版本。您可能会使用值 digits=-3 来获得您想要的确切显示。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-31
    • 1970-01-01
    • 2021-04-21
    相关资源
    最近更新 更多