# Generate Interactive SAR Report # =============================== cat("Generating interactive SAR exploration report...\n") # Install rmarkdown if needed if (!require(rmarkdown)) { install.packages("rmarkdown") library(rmarkdown) } # Set working directory if (basename(getwd()) != "smartcane") { stop("Please run this from the main smartcane directory") } # Render the report report_file <- "r_app/SAR_exploration_report.Rmd" output_file <- "output/SAR_exploration_report.html" cat("Rendering report:", report_file, "\n") cat("Output file:", output_file, "\n") # Render with error handling tryCatch({ rmarkdown::render( input = report_file, output_file = output_file, output_format = "html_document", quiet = FALSE ) cat("\nāœ“ Report generated successfully!\n") cat("Open", output_file, "in your browser to view the interactive maps.\n") # Try to open in browser (Windows) if (.Platform$OS.type == "windows") { shell.exec(normalizePath(output_file)) } }, error = function(e) { cat("āœ— Error generating report:\n") cat(conditionMessage(e), "\n") # Try with minimal content first cat("\nTrying minimal report generation...\n") cat("Check the console output above for specific errors.\n") })