@@ -13,33 +13,46 @@ multilocation_plot_targets <- list(
1313 # (e.g., first, middle, and last forecast date)
1414 # Only select dates that actually have complete forecast data
1515 tar_target(
16- name = selected_forecast_dates_multiloc ,
17- command = {
18- dates <- unique(scores $ forecast_date )
19- dates <- sort(dates )
20-
21- # Filter to only dates with complete data
22- valid_dates <- c()
23- test_loc <- available_locations_multiloc [1 ]
24- for (test_date in dates ) {
25- date_str <- as.character(as.Date(test_date , origin = " 1970-01-01" ))
26- test_path <- file.path(
27- output_path_multiloc ,
28- " individual_forecasts_all_runs" ,
29- date_str ,
30- test_loc ,
31- " data" ,
32- " hosp_quantiles_ww_TRUE.csv"
33- )
34- if (file.exists(test_path )) {
35- valid_dates <- c(valid_dates , date_str )
36- }
16+ name = selected_forecast_dates_multiloc ,
17+ command = {
18+ + test_loc <- available_locations_multiloc [1 ]
19+ dates <- unique(scores $ forecast_date )
20+ dates <- sort(dates )
21+
22+ # Filter to only dates with complete data
23+ valid_dates <- c()
24+ test_loc <- available_locations_multiloc [1 ]
25+ for (test_date in dates ) {
26+ date_str <- as.character(as.Date(test_date , origin = " 1970-01-01" ))
27+ test_path <- file.path(
28+ output_path_multiloc ,
29+ " individual_forecasts_all_runs" ,
30+ date_str ,
31+ test_loc ,
32+ " data" ,
33+ " hosp_quantiles_ww_TRUE.csv"
34+ )
35+ if (file.exists(test_path )) {
36+ valid_dates <- c(valid_dates , date_str )
37+ }
38+ }
39+ date_strs <- as.character(as.Date(dates , origin = " 1970-01-01" ))
40+ valid_dates <- date_strs [vapply(date_strs , function (date_str ) {
41+ test_path <- file.path(
42+ output_path_multiloc ,
43+ " individual_forecasts_all_runs" ,
44+ date_str ,
45+ test_loc ,
46+ " data" ,
47+ " hosp_quantiles_ww_TRUE.csv"
48+ )
49+ file.exists(test_path )
50+ }, logical (1 ))]
51+
52+ # Return every other valid date for clarity
53+ valid_dates [seq(1 , length(valid_dates ), by = 2 )]
3754 }
38-
39- # Return every other valid date for clarity
40- valid_dates [seq(1 , length(valid_dates ), by = 2 )]
41- }
42- ),
55+ ),
4356 # Get available locations from scores
4457 tar_target(
4558 name = available_locations_multiloc ,
0 commit comments