visTree | 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, data = NULL, tooltipColumns = if (!is.null(data)) { 1:ncol(data) } else { NULL }, 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 |
|
data |
|
tooltipColumns |
|
main |
Title. See visNetwork |
submain |
Subtitle. See visNetwork |
footer |
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 https://datastorm-open.github.io/visNetwork/
visTreeEditor, visTreeModuleServer, visNetworkEditor
## Not run: library(rpart) # Basic classification tree res <- rpart(Species~., data=iris) visTree(res, data = iris, 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, data = solder, nodesPopSize = TRUE, minNodeSize = 10, maxNodeSize = 30, height = "800px") # ----- 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")) # Use visNetwork functions to add more options visTree(res) %>% visOptions(highlightNearest = TRUE) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.