I am trying to run a loop on a data frame containing 27820 items. My code looks like
total.male <- list()
for(yr in 1:32) {
num.year = 0
for(i in 1:27820) {
if (suiciderate[i,"sex"] == "male" && suiciderate[i, "Year"] == yr) {
num.year <- num.year + 1
}
total.male <- list(total.male, num.year)
}
}
When I try this, R studio pop up an error and terminate, saying fatal error. I guess maybe there are so much data that leads to this problem. So I reduce this to run the first 1000 items but
why the list is large like this? It's so weird that the size is 3.7MB with only two elements?
Thank you