Skip empty QC plots
This commit is contained in:
@@ -193,6 +193,13 @@ generate_plot <- function(df, x_var, y_var = NULL, plot_type, color_var = "conc_
|
||||
|
||||
generate_and_save_plots <- function(df, output_dir, prefix, variables, include_qc = FALSE) {
|
||||
plots <- list()
|
||||
|
||||
if (nrow(df) == 0) {
|
||||
message("The \"", deparse(substitute(df)), "\" dataframe is empty, skipping plots")
|
||||
return()
|
||||
}
|
||||
|
||||
message("Generating plots for \"", deparse(substitute(df)), "\" dataframe")
|
||||
|
||||
for (var in variables) {
|
||||
scatter_plot <-
|
||||
@@ -269,7 +276,7 @@ save_plots <- function(file_name, plot_list, output_dir) {
|
||||
|
||||
# Save to HTML with horizontal legend orientation
|
||||
lapply(names(plot_list), function(plot_name) {
|
||||
message("Processing plot: ", plot_name)
|
||||
message("Generating plot: ", plot_name)
|
||||
pgg <- tryCatch({
|
||||
suppressWarnings(ggplotly(plot_list[[plot_name]]) %>%
|
||||
layout(legend = list(orientation = "h")))
|
||||
|
||||
Reference in New Issue
Block a user