create_event_tree: Create an Event Tree from a Dataset
Description
This function constructs an event tree from a given dataset based on user-specified categorical variables.
The resulting tree is represented as a graph, where each unique combination of variable values corresponds
to a distinct path in the tree.
A vector of column indices or names specifying which variables to use for constructing the event tree.
label_type
A character string specifying how edge labels should be displayed. Options are "names" (variable names),
"both" (variable names and counts). Default is "both".
level_separation
A numeric value indicating the spacing between levels in the visualization. Default is 1000.
node_distance
A numeric value specifying the horizontal distance between nodes in the visualization. Default is 300.
Details
The function follows these steps:
Extracts the specified columns from the dataset.
Determines unique values for each variable and generates state names dynamically.
Constructs a directed acyclic graph (DAG) using igraph, where each state represents a unique combination of variable values.
Computes transition counts between states.
Uses visNetwork to generate an interactive visualization of the event tree.