| visTree {visNetwork} | R Documentation |
Visualize Recursive Partitioning and Regression Trees rpart. Have a look to visTreeEditor to edity and get back network, or to visTreeModuleServer to use custom tree module in R
visTree(object, main = "", submain = "", footer = "", direction = "UD", fallenLeaves = FALSE, rules = TRUE, simplifyRules = TRUE, shapeVar = "dot", shapeY = "square", colorVar = NULL, colorY = NULL, colorEdges = "#8181F7", nodesFontSize = 16, edgesFontSize = 14, edgesFontAlign = "horizontal", legend = TRUE, legendNodesSize = 22, legendFontSize = 16, legendWidth = 0.1, legendNcol = 1, legendPosition = "left", nodesPopSize = FALSE, minNodeSize = 15, maxNodeSize = 30, highlightNearest = list(enabled = TRUE, degree = list(from = 50000, to = 0), hover = FALSE, algorithm = "hierarchical"), collapse = list(enabled = TRUE, fit = TRUE, resetHighlight = TRUE, clusterOptions = list(fixed = TRUE, physics = FALSE)), updateShape = TRUE, tooltipDelay = 500, digits = 3, height = "600px", width = "100%", export = TRUE)
object |
|
main |
For add a title. See visNetwork |
submain |
For add a subtitle. See visNetwork |
footer |
For add a footer. See visNetwork |
direction |
|
fallenLeaves |
|
rules |
|
simplifyRules |
|
shapeVar |
|
shapeY |
|
colorVar |
|
colorY |
if classification tree :
if regression tree : |
colorEdges |
|
nodesFontSize |
|
edgesFontSize |
|
edgesFontAlign |
|
legend |
|
legendNodesSize |
|
legendFontSize |
|
legendWidth |
|
legendNcol |
|
legendPosition |
|
nodesPopSize |
|
minNodeSize |
|
maxNodeSize |
|
highlightNearest |
|
collapse |
|
updateShape |
|
tooltipDelay |
|
digits |
|
height |
|
width |
|
export |
|
a visNetwork object
See online documentation http://datastorm-open.github.io/visNetwork/
visTreeEditor, visTreeModuleServer, visNetworkEditor
## Not run:
library(rpart)
# Basic classification tree
res <- rpart(Species~., data=iris)
visTree(res, main = "Iris classification Tree")
# Basic regression tree
res <- rpart(Petal.Length~., data=iris)
visTree(res, edgesFontSize = 14, nodesFontSize = 16)
# Complex tree
data("solder")
res <- rpart(Opening~., data = solder, control = rpart.control(cp = 0.00005))
visTree(res, height = "800px", nodesPopSize = TRUE, minNodeSize = 10, maxNodeSize = 30)
# ----- Options
res <- rpart(Opening~., data = solder, control = rpart.control(cp = 0.005))
# fallen leaves + align edges label & size
visTree(res, fallenLeaves = TRUE, height = "500px",
edgesFontAlign = "middle", edgesFontSize = 20)
# disable rules in tooltip, and render tooltip faster
# enable hover highlight
visTree(res, rules = FALSE, tooltipDelay = 0,
highlightNearest = list(enabled = TRUE, degree = list(from = 50000, to = 0),
hover = TRUE, algorithm = "hierarchical"))
# Change color with data.frame
colorVar <- data.frame(variable = names(solder),
color = c("#339933", "#b30000","#4747d1","#88cc00", "#9900ff","#247856"))
colorY <- data.frame(modality = unique(solder$Opening),
color = c("#AA00AA", "#CDAD15", "#213478"))
visTree(res, colorEdges = "#000099", colorVar = colorVar, colorY = colorY)
# Change color with vector
visTree(res, colorEdges = "#000099",
colorVar = substring(rainbow(6), 1, 7),
colorY = c("blue", "green", "orange"))
## End(Not run)