Learn R Programming

stCEG (version 0.1.0)

summary.staged_tree: Summarise a Staged Tree Object

Description

Provides a visual and textual summary of a staged tree object, including counts of nodes and edges, node colour distributions, and uncoloured nodes in intermediate levels.

Usage

# S3 method for staged_tree
summary(object, ...)

Value

Invisibly returns a list containing summary components:

  • num_nodes: Total number of nodes in the staged tree.

  • num_edges: Total number of edges in the staged tree.

  • num_uncoloured_middle: Number of white nodes not in the first or last level.

  • color_counts: A named table of node colour frequencies.

  • priortable: The prior table, if available; otherwise NULL.

Also prints a human-readable summary to the console.

Arguments

object

An object of class staged_tree, containing components nodes and edges in object$stagedtree$x, and optionally a priortable.

...

Additional arguments (currently unused).

Details

This function #prints a summary that includes:

  • Total number of nodes and edges.

  • Number of nodes still uncoloured (white) that are not in the first or last level.

  • A count of nodes by hex colour, optionally with coloured terminal output using the crayon package.

  • The prior table if it exists.

If the crayon package is available, the function displays background colour blocks in the console to represent node colours.

Examples

Run this code
data <- homicides
event_tree <- create_event_tree(data, columns = c(1,2,4,5), "both")
coloured_tree <- ahc_colouring(event_tree)
tree_priors <- specify_priors(coloured_tree, prior_type = "Uniform", ask_edit = FALSE)
staged_tree <- staged_tree_prior(coloured_tree, tree_priors)
homicides_ST_summary <- summary(staged_tree)

Run the code above in your browser using DataLab