Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rpart.plot remove scientific notation

Tags:

> 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

like image 459
Summer Mao Avatar asked Dec 11 '16 22:12

Summer Mao


1 Answers

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.

like image 95
Stephen Milborrow Avatar answered Oct 11 '22 14:10

Stephen Milborrow