inst/examples/example_dendro_rpart.R
raw| 1 | ### Demonstrate rpart |
| 2 | |
| 3 | if (require(rpart)) { |
| 4 | require(ggplot2) |
| 5 | fit <- rpart(Kyphosis ~ Age + Number + Start, method = "class", |
| 6 | data = kyphosis) |
| 7 | fitr <- dendro_data(fit) |
| 8 | ggplot() + |
| 9 | geom_segment(data = fitr$segments, |
| 10 | aes(x = x, y = y, xend = xend, yend = yend) |
| 11 | ) + |
| 12 | geom_text(data = fitr$labels, aes(x = x, y = y, label = label)) + |
| 13 | geom_text(data = fitr$leaf_labels, aes(x = x, y = y, label = label)) + |
| 14 | theme_dendro() |
| 15 | } |