5
> fit <- rpart(price ~ carat + cut + clarity, diamonds_train, method = "anova")

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

I tried options(scipen=10) but it didn't work. How can I remove the scientific notation?

enter image description here

alistaire
  • 42,459
  • 4
  • 77
  • 117
Summer Mao
  • 51
  • 1
  • 4
  • Quoting from the documentation of rpart.plot on digits parameter: The number of significant digits in displayed numbers. Default 2. If 0, use getOption("digits"). Details: Numbers from 0.001 to 9999 are printed without an exponent (and the number of digits is actually only a suggestion, see format for details). Numbers out that range are printed with an “engineering” exponent (a multiple of 3). – Sandeep Jan 10 '17 at 06:25

1 Answers1

5

Use a negative value for the digits argument. The rpart.plot help page says that if digits is negative, rpart.plot uses the standard R format function (with the absolute value of 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)

This requires rpart.plot version 2.1.2 or higher. You may have play with the value digits=-3 to get the exact display you want.

Stephen Milborrow
  • 976
  • 10
  • 14