fixed the path that the excel is being saved to

This commit is contained in:
DimitraVeropoulou 2026-02-16 11:51:10 +01:00
parent 951eb487b8
commit 0503a93bcd
2 changed files with 8 additions and 8 deletions

View file

@ -335,8 +335,8 @@ main <- function() {
message("WORKFLOW: CALCULATING 6 FARM-LEVEL KPIs (Script 90 compatible)")
message(strrep("=", 70))
# Prepare inputs for KPI calculation (already created by setup_project_directories)
reports_dir_kpi <- setup$kpi_reports_dir
# Prepare outputs and inputs for KPI calculation (already created by setup_project_directories)
reports_dir_kpi <- file.path(setup$reports_dir, "kpis")
cumulative_CI_vals_dir <- setup$cumulative_CI_vals_dir
# Load field boundaries for workflow (use data_dir from setup)

View file

@ -678,13 +678,13 @@ export_field_analysis_excel <- function(field_df, summary_df, project_dir, curre
NULL
}
output_subdir <- file.path(reports_dir, "field_analysis")
if (!dir.exists(output_subdir)) {
dir.create(output_subdir, recursive = TRUE)
output_dir <- file.path(reports_dir)
if (!dir.exists(output_dir)) {
dir.create(output_dir, recursive = TRUE)
}
excel_filename <- paste0(project_dir, "_field_analysis_week", sprintf("%02d_%d", current_week, year), ".xlsx")
excel_path <- file.path(output_subdir, excel_filename)
excel_path <- file.path(output_dir, excel_filename)
excel_path <- normalizePath(excel_path, winslash = "\\", mustWork = FALSE)
# Build sheets list dynamically
@ -710,13 +710,13 @@ export_field_analysis_excel <- function(field_df, summary_df, project_dir, curre
)
rds_filename <- paste0(project_dir, "_field_analysis_week", sprintf("%02d_%d", current_week, year), ".rds")
rds_path <- file.path(output_subdir, rds_filename)
rds_path <- file.path(output_dir, rds_filename)
saveRDS(kpi_data, rds_path)
message(paste("✓ Field analysis RDS exported to:", rds_path))
csv_filename <- paste0(project_dir, "_field_analysis_week", sprintf("%02d_%d", current_week, year), ".csv")
csv_path <- file.path(output_subdir, csv_filename)
csv_path <- file.path(output_dir, csv_filename)
write_csv(field_df_rounded, csv_path)
message(paste("✓ Field analysis CSV exported to:", csv_path))