# 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")
paths = list.dirs(path = "data", recursive = F) paths = paths[grep("sim", paths)] # read data and summarise distance and displacement data = lapply(paths, function(path) { df_ = read_data(path, gen_start = 0, gen_end = 240, gen_add = 249) df_ = df_[, list(paths = list(.SD)), by = c("id", "g")] df_[, c("displacement", "distance") := list( vapply(paths, get_displacement, FUN.VALUE = 1.0), vapply(paths, get_distance, FUN.VALUE = 1L) )] df_[, c("id", "g", "distance", "displacement")] })
params = lapply(paths, read_config) # add parameters data = Map(function(df, p) { df[, names(p) := list(p["growth"], p["type"], p["rep_"])] }, data, params)
# get wt and fitness data wt_data = lapply(paths, get_wt_data, gen_start = 0, gen_end = 240, gen_add = 249, n_agents = 100) data = Map(data, wt_data, f = function(df_, wt_) { merge(df_, wt_, by.x = c("id", "g"), by.y = c("id", "gen")) }) # bind and save data = rbindlist(data) # exclude gen 250 data = data[g < 250,] # save fwrite(data, file = "data/data_gens_dist_summary.csv")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.