diff --git a/R/calculate_forecasts_anomalies.R b/R/calculate_forecasts_anomalies.R index 37d1238..19e1901 100644 --- a/R/calculate_forecasts_anomalies.R +++ b/R/calculate_forecasts_anomalies.R @@ -30,7 +30,13 @@ calculate_forecasts_anomalies <- function(ecmwf_forecasts_transformed, existing_files <- list.files(forecasts_anomalies_directory) if(save_filename %in% existing_files & !overwrite) { message("file already exists, skipping download") + saved <- read_parquet(file.path(forecasts_anomalies_directory, save_filename)) + saved_check <- col_na(saved) + if(!any(saved_check)) { return(file.path(forecasts_anomalies_directory, save_filename)) + }else{ + message("NAs found, regenerating file") + } } # Open dataset to transformed data diff --git a/R/utils.R b/R/utils.R index 929c908..b8a7ea7 100644 --- a/R/utils.R +++ b/R/utils.R @@ -26,4 +26,7 @@ all_targets <- function(env = parent.env(environment()), type = "tar_target") { # # tar_load_s3 <- function(target_name, ...) { # -# } \ No newline at end of file +# } + +#' Get NAs +col_na <- function(df) purrr::map_lgl(df, ~any(is.na(.)))