From b83567bc2d33ed18be4745121c95ca2b3de6119f Mon Sep 17 00:00:00 2001 From: eduzenli Date: Wed, 31 May 2023 18:25:59 +0200 Subject: [PATCH] fun_analog function min-max problem solved --- R/Analogs.R | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/R/Analogs.R b/R/Analogs.R index f0ebd61..230102d 100644 --- a/R/Analogs.R +++ b/R/Analogs.R @@ -480,6 +480,10 @@ Analogs <- function(exp, obs, exp_lats, exp_lons, obs_lats, obs_lons, grid_exp, if (fun_analog == "wmean") { weight <- 1 / dist res <- apply(res, c(1,2), function(x) weighted.mean(x, weight)) + } else if (fun_analog == "min") { + res<-res[,,which.min(dist)] + } else if (fun_analog == "max") { + res<-res[,,which.max(dist)] } else { res <- apply(res, c(1,2), fun_analog) } -- GitLab