File tree Expand file tree Collapse file tree 3 files changed +13
-1
lines changed Expand file tree Collapse file tree 3 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -559,6 +559,10 @@ engine_gdb <- function(x,
559
559
newdata $ rowid <- 1 : nrow(newdata )
560
560
# Subset to non-missing data
561
561
newdata_sub <- subset(newdata , stats :: complete.cases(newdata ))
562
+ if (nrow(newdata_sub )== 0 ) {
563
+ cli :: cli_alert_danger(" Every observation has missing data?" )
564
+ newdata_sub <- newdata
565
+ }
562
566
563
567
if (getOption(" ibis.runparallel" ,default = FALSE )){
564
568
check_package(" doFuture" )
Original file line number Diff line number Diff line change @@ -860,6 +860,10 @@ engine_glmnet <- function(x,
860
860
# Make a subset of non-na values
861
861
df $ rowid <- 1 : nrow(df )
862
862
df_sub <- base :: subset(df , stats :: complete.cases(df ))
863
+ if (nrow(df_sub )== 0 ) {
864
+ cli :: cli_alert_danger(" Every observation has missing data?" )
865
+ df_sub <- df
866
+ }
863
867
if (! is.Waiver(model $ offset )) ofs <- model $ offset [df_sub $ rowid ] else ofs <- NULL
864
868
assertthat :: assert_that(nrow(df_sub )> 0 )
865
869
Original file line number Diff line number Diff line change @@ -806,7 +806,11 @@ methods::setMethod(
806
806
807
807
# --- #
808
808
# Now predict
809
- out <- x $ project(newdata = env , layer = layer )
809
+ out <- try({ x $ project(newdata = env , layer = layer ) })
810
+ if (inherits(out , ' try-error' )){
811
+ cli :: cli_alert_danger(" Projection failed! Returning emptyraster gracefully" )
812
+ return (template )
813
+ }
810
814
names(out ) <- paste0(" suitability" , " _" , layer )
811
815
if (is.na(terra :: crs(out ))) terra :: crs(out ) <- terra :: crs( model $ background )
812
816
# --- #
You can’t perform that action at this time.
0 commit comments