2
library(rpart)
library(rpart.plot)
fit <- rpart(Kyphosis ~ Age + Number + Start, data = kyphosis)
prp(fit, type = 4, extra = 101, leaf.round = 1, fallen.leaves = TRUE,
    varlen = 0, tweak = 0.8)

enter image description here

I'm trying to get the text to fit inside the rounded squares. I tried lowering the tweak and cex values, but it appears that the rounded squares get smaller along with the text. How can I make the font size smaller?

Bulat
  • 6,869
  • 1
  • 29
  • 52
Adrian
  • 9,229
  • 24
  • 74
  • 132

2 Answers2

4

Try out this graphical package instead:

library(maptree)
draw.tree(fit,cex=3)

Change cex to get different font sizes.

Otto_K
  • 347
  • 2
  • 6
0

Using the same package - rpart.plot

fancyRpartPlot(fit,cex=3)

Change cex as better suites your case, as explained by Otto_k.

Nemesi
  • 781
  • 3
  • 13
  • 29