RStudio Fatal error - session aborted

Hi guys

I've been looking in the web and I can't find the reasons why RStudio crashes with fatal error and session aborts.

I've been running into this error for some time. At first, I thought it was some random error but then it persisted. It appears when I'm running for cycles, and I would like you to help me understanding why. Thanks in advance.

So my code is the following:

setwd("C:\\Users\\user\\Desktop\\MThesis\\Cenarios\\Variacoes sem aproximacao temporal\\USANDO MOLTENS ANTERIORES")
rm(list = ls())

library(ggplot2)
library(data.table)
library(dplyr)
library(gridExtra)
library(grid)


totInf12 <- fread("12epidemic2.csv")
cenario <- rep(12,nrow(totInf12))
totInf12 <- cbind(totInf12, cenario)
div12 <- fread("12molten_means.csv")
cenario <- rep(12,nrow(div12))
div12 <- cbind(div12, cenario)

totInf13 <- fread("13epidemic2.csv")
cenario <- rep(13,nrow(totInf13))
totInf13 <- cbind(totInf13, cenario)
div13 <- fread("13molten_means.csv")
cenario <- rep(13,nrow(div13))
div13 <- cbind(div13, cenario)

totInf14 <- fread("14epidemic2.csv")
cenario <- rep(14,nrow(totInf14))
totInf14 <- cbind(totInf14, cenario)
div14 <- fread("14molten_means.csv")
cenario <- rep(14,nrow(div14))
div14 <- cbind(div14, cenario)

totInf9 <- fread("9epidemic2.csv")
cenario <- rep(9,nrow(totInf9))
totInf9 <- cbind(totInf9, cenario)
div9 <- fread("9molten_means.csv")
cenario <- rep(9,nrow(div9))
div9 <- cbind(div9, cenario)

totInf10 <- fread("10epidemic2.csv")
cenario <- rep(10,nrow(totInf10))
totInf10 <- cbind(totInf10, cenario)
div10 <- fread("10molten_means.csv")
cenario <- rep(10,nrow(div10))
div10 <- cbind(div10, cenario)

totInf11 <- fread("11epidemic2.csv")
cenario <- rep(11,nrow(totInf11))
totInf11 <- cbind(totInf11, cenario)
div11 <- fread("11molten_means.csv")
cenario <- rep(11,nrow(div11))
div11 <- cbind(div11, cenario)

l_div <- list(div9,div10,div11,div12,div13,div14)
divs <- rbindlist(l_div , use.names = FALSE, fill= FALSE, idcol = NULL)

l_inf <- list(totInf9, totInf10, totInf11, totInf12, totInf13, totInf14)
totInf <- rbindlist(l_inf, use.names = FALSE, fill = FALSE, idcol = NULL)


epidemias <- fread("select_com_apox.csv")


#calculo de duracoes de epidemias
duracoes <- data.table(cen=factor(), sim=numeric(), dur=numeric())
for (cenar in 9:14) {
  tabela <- epidemias[cen ==cenar]
  for (siml in unique(tabela$sim)) {
    calc <-nrow(totInf[(cenario==cenar)&(sim==siml)])
    poe<-list(cenar, siml, calc)
    duracoes <- rbind(duracoes, poe)
  }
}

# as.numeric(gsub("sim","",epidemias$sim))

dados <- data.table(cen=factor(), sim=numeric(), time=numeric(), totInf=numeric(), div=numeric())
for (cenar in unique(epidemias$cen)) {
  print(cenar)
  
  for (siml in unique(epidemias$sim[epidemias$cen == cenar])) {
    duracao <- duracoes[(cen==cenar)&(sim ==siml)]
    print(siml)
    div_times <- seq(0,duracao$dur, 24)
    
    for (j in 1:length(div_times)) {
      infetados_t <- totInf$totInf[(totInf$cenario==cenar)&(totInf$sim==siml)&(totInf$time==div_times[j])]
      divs_t <- divs$variable[(divs$cenario==cenar)&(divs$variable==paste("sim",siml,sep = ""))&(divs$div_sample_times==div_times[j])]
      poe <- list(cenar, siml, div_times[j],infetados_t, divs_t)
      dados <- rbind(dados, poe)
      }
    
  }
}
fwrite(dados, "final_para_caculos.csv")

Hi. It's not a great idea to use spaces in directories. Still, a good idea to get started is to boot RStudio, click the upper right hand 'R Project" icon, then click "new project," then "existing directory," and then steer to the directory associated with setwd in your code above. You won't then need to use setwd for this code, as the Rproj will be situated and call and write data from/to that directory. Hope this helps.

Thank you for your answer. I will start doing that from now on!

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.