Skip to content

Commit

Permalink
na.rm for EMwmean
Browse files Browse the repository at this point in the history
  • Loading branch information
HeleneBlt committed Aug 1, 2024
1 parent e1394bb commit e82f7b9
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions R/biomod2_classes_5.R
Original file line number Diff line number Diff line change
Expand Up @@ -691,10 +691,11 @@ setMethod('predict2', signature(object = 'EMwmean_biomod2_model', newdata = "dat
if (ncol(newdata) < 1) {
stop("Model EMwmean was not computed because no single model was kept in ensemble modeling")
}
predfun <- function(newdata, on_0_1000, penalization_scores, ...){
out <- as.vector(
as.matrix(newdata) %*% penalization_scores
)
predfun <- function(newdata, on_0_1000, penalization_scores, na.rm, ...){
# out <- as.vector(
# as.matrix(newdata) %*% penalization_scores
# )
out <- as.vector(rowSums(t(apply(as.matrix(newdata), 1, function(x) penalization_scores*x)), na.rm = na.rm))
if (on_0_1000) {
out <- round(out)
}
Expand Down

0 comments on commit e82f7b9

Please sign in to comment.