inst/examples/example_dendro_rpart.R

### Demionstrate rpart

if(require(rpart)){
  require(ggplot2)
  fit <- rpart(Kyphosis ~ Age + Number + Start, method="class", data=kyphosis)
  fitr <- dendro_data(fit)
  ggplot() + 
    geom_segment(data=fitr$segments, aes(x=x, y=y, xend=xend, yend=yend)) + 
    geom_text(data=fitr$labels, aes(x=x, y=y, label=label)) +
    geom_text(data=fitr$leaf_labels, aes(x=x, y=y, label=label)) +
    theme_dendro()
}

Try the ggdendro package in your browser

Any scripts or data that you put into this service are public.

ggdendro documentation built on May 29, 2017, 9:39 p.m.