Skip to contents

Use a Highcharts treegraph for a partykit::ctree() fit, an rpart classification or ANOVA tree, or a single C5.0 tree. The adapters use partykit when charting a tree. For rpart, fit with model = TRUE to retain the model frame when the training data may be unavailable.

Usage

# S3 method for class 'constparty'
hchart(object, ..., node_shape = c("donut", "bar"), node_size = 64)

# S3 method for class 'rpart'
hchart(object, ...)

# S3 method for class 'C5.0'
hchart(object, ...)

Arguments

object

A fitted constparty, rpart, or C5.0 model.

...

Additional Highcharts treegraph series options.

node_shape

Classification marker, either "donut" or "bar".

node_size

Root diameter in pixels, or the equivalent area for a bar.

Value

A highchart htmlwidget.

Details

Node area represents the number of training rows. Classification nodes show observed class proportions in factor level order. Regression nodes show the observed mean on a shared color axis. Counts and summaries are unweighted. Hover over a node for its summary and, when stored by the fit, the split variable's association p-value. Click a split to fold it.

Examples

fit <- partykit::ctree(Species ~ Petal.Length + Petal.Width, data = iris)
hchart(fit, node_shape = "bar") |>
  hc_colors(c("#087B71", "#AD591D", "#7655A0"))