Skip to content

Commit

Permalink
Speedup loop_ecology that was too slow for the evol simulation
Browse files Browse the repository at this point in the history
  • Loading branch information
ZHG2017 committed Apr 28, 2022
1 parent 38327c4 commit ea08069
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions R/ecology.R
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,10 @@ loop_ecology <- function(config, data, vars) {
chars <- as.character(die_sure)
} #end of check if any die_sure
} #end loop over ids with at least one species...
species_list <- list()
for (species in data$all_species) {
cells <- names(species[["abundance"]])[species[["abundance"]] != 0]
updated_species <- limit_species_to_cells(species, cells)
species_list <- append(species_list, list(updated_species))
}

species_list <- vector(mode = "list", length = length(data$all_species))

species_list <- lapply(data$all_species, function(i){limit_species_to_cells(i, names(i[["abundance"]])[i[["abundance"]] != 0])})
data$all_species <- species_list

if(config$gen3sis$general$verbose>=3){
Expand Down

0 comments on commit ea08069

Please sign in to comment.