Skip to contents

Given the results of the splitting and testing algorithm in the form of a graph from make_results_tree, make a node level data set for use in reporting results in terms of a binary tree graph. This does not print or plot the graph. You'll need to do that with the resulting object.

Usage

make_results_ggraph(res_graph, remove_na_p = TRUE)

Arguments

res_graph

A tidygraph object produced from make_results_tree

remove_na_p

A logical indicating whether the graph should include nodes/leaves that were not tested. Default (TRUE) is to remove them. When remove_na_p is FALSE, the graph might look strange since some blocks will not have a known position in the graph (the graph is fixed, but not specified by the find_blocks function when a node or block is not visited for testing.)

Value

A ggraph object

Examples

if (FALSE) { # \dontrun{
# Complete workflow example
data(example_dat, package = "manytestsr")
library(data.table)
library(dplyr)

# Create block-level dataset
example_bdat <- example_dat %>%
  group_by(blockF) %>%
  summarize(
    nb = n(),
    pb = mean(trt),
    hwt = (nb / nrow(example_dat)) * (pb * (1 - pb)),
    .groups = "drop"
  ) %>%
  as.data.table()

# Run find_blocks
results <- find_blocks(
  idat = example_dat,
  bdat = example_bdat,
  blockid = "blockF",
  splitfn = splitCluster,
  pfn = pOneway,
  fmla = Y1 ~ trtF | blockF,
  parallel = "no"
)

# Create tree structure
tree_results <- make_results_tree(results, block_id = "blockF")

# Create ggraph visualization
library(ggraph)
library(ggplot2)
graph_plot <- make_results_ggraph(tree_results$graph)

# Display the plot
print(graph_plot)

# Customize the visualization
graph_plot +
  labs(title = "Hierarchical Testing Results Tree") +
  theme_void()
} # }