generate_spaghetti_plot_from_results {detectXOR} | R Documentation |
Generate XOR Spaghetti Plots
Description
Creates connected line plots for variable pairs showing XOR patterns.
Usage
generate_spaghetti_plot_from_results(
results,
data,
class_col,
scale_data = TRUE
)
Arguments
results |
Either a data frame from |
data |
Original dataset containing variables and classes |
class_col |
Character string specifying the name of the class column |
scale_data |
Logical indicating whether to scale variables before plotting (default: TRUE) |
Details
This function creates spaghetti plots (connected line plots) for variable pairs that have been flagged as showing XOR patterns by detect_xor()
. The function automatically handles both original and rotated XOR patterns, applying the appropriate coordinate transformation when necessary.
The function accepts either the full results object returned by detect_xor()
or just the results_df
component extracted from it. Variable pairs are separated using "||" as the delimiter in plot labels.
If no XOR patterns are detected, an empty plot with an appropriate message is returned.
To save the plot, use ggplot2::ggsave()
or other standard R plotting save methods.
Value
Returns a ggplot object. No files are saved automatically.
See Also
detect_xor
for XOR pattern detection, generate_xy_plot_from_results
for scatter plots
Examples
# Using full results object (recommended)
data(XOR_data)
results <- detect_xor(data = XOR_data, class_col = "class")
spaghetti_plot <- generate_spaghetti_plot_from_results(
results = results,
data = XOR_data,
class_col = "class"
)
# Display the plot
print(spaghetti_plot)
# Save the plot if needed
# ggplot2::ggsave("my_spaghetti_plot.png", spaghetti_plot)
# Using extracted results_df (also works)
xy_plot <- generate_spaghetti_plot_from_results(
results = results$results_df,
data = XOR_data,
class_col = "class"
)