From 439440e8d61cb38e778de55d36bf08869cf0c58e Mon Sep 17 00:00:00 2001 From: eduzenli Date: Tue, 30 Jan 2024 16:09:57 +0100 Subject: [PATCH] return value problem for entire-space-NA was solved --- R/Analogs.R | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/R/Analogs.R b/R/Analogs.R index 062425f..73b76ae 100644 --- a/R/Analogs.R +++ b/R/Analogs.R @@ -545,6 +545,10 @@ Analogs <- function(exp, obs, exp_lats = NULL, exp_lons = NULL, obs_lats, obs_lo if (all(is.na(test))) { res <- array(NA, space_dims_hres) + res_ind <- array(NA, k) + names(dim(res_ind)) <- c("index") + res_metric <- array(NA, k) + names(dim(res_metric)) <- c("metric") } else { if (metric == "dist") { dist_all <- sqrt(rowSums((sweep(tr_wo_na, 2, te_wo_na[1,]))^2)) # euc dist @@ -587,8 +591,8 @@ Analogs <- function(exp, obs, exp_lats = NULL, exp_lons = NULL, obs_lats, obs_lo res <- apply(res, c(1,2), fun_analog) } } - return(list(res, res_ind, res_metric)) } + return(list(res, res_ind, res_metric)) } # Add the dimension window to an array that contains, at least, the start date and time -- GitLab