rstudio.cloud instance crashing after the following

My Rstudio cloud is crashing when I run the below code. Is it because of the 1GB limit on memory? What is a solution?

getwd()

setwd("/cloud/project")

load("/cloud/project/addhealth_1.RData")

new <- addhealth_1

new <- new[order(new$AID, decreasing = FALSE), ]

library(descr)

freq(new$BIO_SEX)
freq(new$age1)
freq(new$H1GI20)

new$BIO_SEX[new$BIO_SEX == 6] <- NA
new$H1GI20 [new$H1GI20 >= 96] <- NA

new$AGEGROUP[new$age1 <= 16.51] <- 1
new$AGEGROUP[new$age1 > 16.51] <- 2

freq(new$AGEGROUP)

new$OLDER4GRADE <- 0
new$OLDER4GRADE[is.na(new$H1GI20)|is.na(new$age1)] <- NA
new$OLDER4GRADE[new$H1GI20==7 & new$age1>=14|
new$H1GI20==8 & new$age1>=15|new$H1GI20==9 & new$age1>=16|
new$H1GI20==10 & new$age1>=17|new$H1GI20==11 & new$age1>=18|
new$H1GI20==12 & new$age1>=19] <- 1

freq(new$OLDER4GRADE)

library(Hmisc)

label(new$age1) <- "age"
label(new$BIO_SEX) <- "gender 1=male 2=female"
label(new$AGEGROUP) <- "age group"
label(new$OLDER4GRADE) <- "older for grade"
label(new$H1GI20) <- "grade level"

freq(new$age1)
freq(new$BIO_SEX)
freq(new$AGEGROUP)
freq(new$OLDER4GRADE)
freq(new$H1GI20)
describe(new$age1)
describe(new$H1GI20)

subset_male <- new[new$BIO_SEX == 1, ]
subset_female <- new[new$BIO_SEX == 2, ]

freq(subset_male$OLDER4GRADE)
freq(subset_female$OLDER4GRADE)

new$H1PF35 [new$H1PF35 >= 6] <- NA

new$FEELSOCACCEPT <- ifelse(is.na(new$H1PF35), NA,
ifelse(new$H1PF35<=2, 1,
ifelse(new$H1PF35<=5, 0, NA)))

label(new$FEELSOCACCEPT) <- "Feeling socially accepted"

freq(new$FEELSOCACCEPT)

subset_male <- new[new$BIO_SEX == 1, ]
subset_female <- new[new$BIO_SEX == 2, ]

freq(subset_male$FEELSOCACCEPT)
freq(subset_female$FEELSOCACCEPT)

sub_older<-new[new$OLDER4GRADE==1,]
sub_younger<-new[new$OLDER4GRADE==0,]

freq(sub_older$FEELSOCACCEPT)
freq(sub_younger$FEELSOCACCEPT)

sub_older_male<-new[(new$OLDER4GRADE==1 & new$BIO_SEX==1),]
sub_older_fem<-new[(new$OLDER4GRADE==1 & new$BIO_SEX==2),]
sub_younger_male<-new[(new$OLDER4GRADE==0 & new$BIO_SEX==1),]
sub_younger_fem<-new[(new$OLDER4GRADE==0 & new$BIO_SEX==2),]

freq(sub_older_male$FEELSOCACCEPT)
freq(sub_older_fem$FEELSOCACCEPT)
freq(sub_younger_male$FEELSOCACCEPT)
freq(sub_younger_fem$FEELSOCACCEPT)

The general steps to approach RStudio crashing can be found at the following guide;


Another way to improve the chances of people helping is to provide a reproducible example.

A minimal REPRoducible EXample (reprex)? A reprex makes it much easier for others to understand your issue and figure out how to help.

Right now your code refers to data and your environment that folks won't have access to.


You might also provide a public link to your rstudio.cloud instance.

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