project-gen3sis / R-package

Repository of the R-packageGen3sis
https://project-gen3sis.github.io/R-package/
GNU General Public License v3.0
29 stars 9 forks source link

plot_summary fails if simulation ends before reaching step 0 #39

Closed benj919 closed 3 years ago

benj919 commented 4 years ago

make_summary hardcodes richness_final to sgen3sis$summary <- c(data$summaries, list("richness-final"=data$geo_richness[,c(1,2,ncol(data$geo_richness))]))

This will be all NAs if the simulation aborts (too many species) or if end_time is not 0. Subsequently this:

  ras <- rasterFromXYZ(output$summary$`richness-final`)
  rc <- color_richness(max(ras@data@values, na.rm=TRUE) + 1)

will call max() with an all NA vector which will return -Inf. Of course a colorRampPalette can't produce -Inf many colours and it fails.