Since visNetwork_2.0.0, you can visualize Classification and Regression Trees from the output of the rpart package, simply using visTree :

Classification Tree

library(rpart)

# Basic classification tree
res <- rpart(Species~., data=iris)
visTree(res, main = "Iris classification Tree", width = "100%")

Regression tree

res <- rpart(Petal.Length~., data=iris)
visTree(res, edgesFontSize = 14, nodesFontSize = 16, width = "100%")
data("solder")
res <- rpart(Opening~., data = solder, control = rpart.control(cp = 0.00005))
visTree(res, height = "800px", nodesPopSize = TRUE, minNodeSize = 10, 
        maxNodeSize = 30, width = "100%")

Use in shiny

Have a look at visTreeEditor to edit and get back to the network, and at visTreeModuleServer to use custom tree module in R.

© 2016-2017 DataStorm

Fork me on GitHub