# load libraries library(data.table) library(glue) library(stringr) # source funs source("R/fun_dist_disp.R") source("R/fun_read_pos.R") source("R/fun_steplength_timescale.R") source("R/fun_read_config.R") source("R/fun_wt_vals.R")
needs to be made recursive over dirs.
paths = list.dirs(path = "data", recursive = F) paths = paths[grep("sim", paths)] # get weight data data = lapply( paths, get_wt_data, gen_start = 250, gen_end = 250, gen_add = NULL, n_agents = 5000 )
params = lapply(paths, read_config)
data = Map(function(df, p) { df[, names(p) := list(p["growth"], p["type"], p["rep_"])] }, data, params) data = rbindlist(data)
fwrite(data, file = "data/data_lt_wt_gens.csv")
# read the data in if needed data = fread("data/data_lt_wt_gens.csv") # select movement weights data = data[, !(sprintf("wt_%i", c(1, seq(6, 8))))] # scale by sum of absolute values data[, wt_abs_sum := apply( data[, c("wt_2", "wt_3", "wt_4")], 1, FUN = function(x) { sum(abs(x)) }) ] data[, c("wt_2", "wt_3", "wt_4") := lapply( .SD, `/`, wt_abs_sum ), .SDcols = c("wt_2", "wt_3", "wt_4")] # assign foraging strategy data[, comp_strat := dplyr::case_when( type == "obligate" & wt_5 < 0 ~ "klept", type == "interf" ~ "mixed", T ~ "forager" )] # remove wt_5 data$wt_5 = NULL
Save scaled weights.
fwrite(data, file = "data/data_lt_wts_scaled.csv")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.