View source: R/generate_plots_from_results.R
generate_spaghetti_plot_from_results | R Documentation |
Creates connected line plots for variable pairs showing XOR patterns.
generate_spaghetti_plot_from_results(
results,
data,
class_col,
scale_data = TRUE
)
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) |
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.
Returns a ggplot object. No files are saved automatically.
detect_xor
for XOR pattern detection, generate_xy_plot_from_results
for scatter plots
# 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"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.