Search code examples
rtreerpart

rpart rounding values


I'm trying to plot a model called "fit" that I created using the rpart package. My problem is that the number on the plot are being rounded. For example, if I run

plot(fit)
text(fit)

I get the 11.75 value, which is the one I'm expecting because if I type fit, I can see:

    alcohol< 11.75 1661  77 Bad (0.953642384 0.046357616)

but If I do:

  prp(fit)

I get the "<12" bellow:

enter image description here

I'd like to use the prp method because it allows me to plot nicer trees, but how can I make it plot the correct value?

thanks


Solution

  • You can increase the significant digits displayed in prp, which defaults at 2. I think you are looking for 4 digits, in which case prp(fit, digits=4) should do the trick for you.