Support with R error code: Error in if (getOption("scipen") <= min(digits)) { : missing value where TRUE/FALSE needed

280 Views Asked by At

Hi I am trying to run ENMeval on occurrence data and some rasters to determine settings for MaxEnt modelling. Whenever I try to run some of my code containing the raster layers, ie:

#resample layer
Elevation_resample <- resample(Elevation, FC, method = "bilinear")
Error in if (getOption("scipen") <= min(digits)) { : 
  missing value where TRUE/FALSE neededtype here
#reclassify layer
FC_rc <- reclassify(FC, matrix(c(NA, 0), ncol = 2))
Error in if (getOption("scipen") <= min(digits)) { : 
  missing value where TRUE/FALSE needed
#reclassify layer
Elevation_rc <- reclassify(Elevation, cbind(NA, 0))
Error in if (getOption("scipen") <= min(digits)) { : 
  missing value where TRUE/FALSE needed
#look for NA values in the raster
na_cells <- is.na(Elevation)
Error in h(simpleError(msg, call)) : 
  error in evaluating the argument 'filename' in selecting a method for function 'writeStart': missing value where TRUE/FALSE needed

I get the same error code coming up (this also comes up when I run ENMevaluate.

Any help with how I can get around this would be massively appreciated. I assumed it was something to do with having NA values but when I try to replace them with zero values that also gives the same message (see above)?

I have tried to turn the NA values in my raster datasets to 0 values but that does not seem to work. I have tried to restart and look for any packages I might be missing but also have no luck. At the moment I am stuck on the code above.

1

There are 1 best solutions below

1
KitS On

I installed R 4.3.1 recently on a new machine, and I encountered a similar error when running an old script of mine that did raster manipulation. But the error vanished when I rolled back to 4.2.3. I haven't tried with 4.3.0 yet. But my guess is that it's a bug in version 4.3.1.