From 4e45539d4e27d59416f7657fc2d2e4e13d19f4ed Mon Sep 17 00:00:00 2001 From: Leon Schwartz Date: Fri, 24 Nov 2023 15:05:57 +0100 Subject: [PATCH] Fixed crash after individual model finished with warning --- R/fn_elastic_net.R | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/R/fn_elastic_net.R b/R/fn_elastic_net.R index cf45440..0a78845 100644 --- a/R/fn_elastic_net.R +++ b/R/fn_elastic_net.R @@ -64,8 +64,12 @@ fn_elasticnet <- function(x, y, alpha.step = 0.1){ }) } - models.cvm <- unlist(lapply(models, function(model){ - min(model$cvm) + models.cvm <- unlist(lapply(models, function(model) { + if (!is.na(model)) { + return(min(model$cvm)) + } else { + return(Inf) + } })) #return model with smallest residual sum of squares