0

0. Session information

> sessionInfo()
R version 4.1.0 (2021-05-18)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19042)

1. Summary of my issue

I am having a crash while using a modified function of response.plot2(), named response.plot3(). The problem is not the function in itself, as the same problem occurs with response.plot2().

image

2. Code

library(biomod2)
library(raster)
library(reshape)
library(ggplot2)

setwd("xxx")

# I load the modified version of response.plot2()
source("/response.plot_modified.R", local = TRUE)

sp <- "NAME"
baseline_EU <- readRDS("./data/baseline_EU.rds")

initial.wd <- getwd()
setwd("models") 

# Loading of formatted data and models calibrated by biomod
load(paste0(sp, "/run.data"))
load(paste0(sp, "/model.runs"))

# Variables used for calibration
cur.vars <- model.runs@expl.var.names
  
# Loading model names into R memory
models.to.plot <- BIOMOD_LoadModels(model.runs)
 
# Calculation of response curves with all models (stored in the object resp which is an array)
resp <- response.plot3(models = models.to.plot,
                         Data = baseline_EU[[cur.vars]],
                         fixed.var.metric = "sp.mean",
                         show.variables = cur.vars,
                         run.data = run.data)

I have got 60 models and the code plot the first curve before aborting the session, with no further explanation.

3. What I unsuccessfully tried

(1) check that it was not a ram issue (2) uninstall-reinstall all the packages and their dependencies (3) uptade to the last R version (4) go back to response.plot2() to see if the issue could come from response.plot3()

4. I found some similar errors which lead me to think that it might be a package issue

https://github.com/rstudio/rstudio/issues/9373

Call to library(raster) or require(raster) causes Rstudio to abort session

Now I presume that there is a problem either with the biomod2 or the raster packages, or maybe the R version?

I would greatly appreciate your help if you have any ideas.

Recology
  • 165
  • 1
  • 10
  • If I recall correctly you're reposting this question? Unfortunately there's really very little we can do without a [mcve] ... see e.g. [this question](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). In particular, (1) we don't have data; (2) we have no idea what's in your modified plotting code (`response.plot_modified.R`). The RStudio crash you're seeing is very generic; your linked questions don't necessarily have much in common with your problem ... The only thing I can suggest to try is to run your code in a plain R console, to confirm ... – Ben Bolker May 21 '21 at 00:24
  • 1
    ... or rule out the suggestion that it's RStudio-specific. Your first link provides a pointer to a patched release of RStudio that should solve the problem if it *is* related to the combination of R 4.1.0 + ggplot2 + RStudio ... https://www.rstudio.com/products/rstudio/download/preview/ – Ben Bolker May 21 '21 at 00:24
  • 1
    Does your code work if you run it in R directly (i.e. NOT using Rstudio)? – Phil May 21 '21 at 02:46
  • @BenBolker yes you recall correctly, I realized that my question at the time was not clear enough, which I tried to correct in the past few days. I will try to run in a plain R console as suggested by you and Phil and I will try to create a minimal reproducible example. – Recology May 21 '21 at 08:23
  • @BenBolker & Phil, thank you for your contribution, the code runs using just a plain R console! So it is RStudio-specific? Any tips on where to look for? – Recology May 21 '21 at 09:00
  • 1
    did you install the patched RStudio from [here](https://www.rstudio.com/products/rstudio/download/preview/) ? – Ben Bolker May 21 '21 at 13:08
  • 1
    This is maybe related to https://stackoverflow.com/questions/67627539/r-4-1-0-crashes-when-trying-to-ggplot I have the same problem: ``` library(ggplot2) ggplot(cars, aes(x=speed)) + geom_histogram() ``` See screnn capture: https://i.stack.imgur.com/JGMGk.png – DanielBonnery May 23 '21 at 21:49
  • https://stackoverflow.com/questions/67638836/r-crashing-while-displaying-ggplot-after-update-process-memory-read-out-of-rang/67638944#67638944 – Ben Bolker May 23 '21 at 21:53
  • 1
    It's *likely* that this is a duplicate of https://stackoverflow.com/questions/67638836/r-crashing-while-displaying-ggplot-after-update-process-memory-read-out-of-rang/67638944#67638944 , but ideally we would get confirmation from the OP (i.e., a statement that downgrading to R 4.0x or installing the patched version of RStudio resolved the problem) – Ben Bolker May 23 '21 at 22:04
  • I am sorry, I had to use my computer for long running codes, but I will try to install the patched RStudio as soon as possible and keep you updated. Regarding the R version, I had the same issue with R 4.0 and installed the newest version 4.1 and had the same problem. – Recology May 24 '21 at 11:49
  • @BenBolker, as your answer of using a plain R console was enough to get past my issue, if you want to post it as an answer I can give you the tick ;) – Recology May 24 '21 at 11:50

0 Answers0