View source: R/gather_simulation.r
summarize.sims | R Documentation |
data.frame
each row of which contains the parameters and the data from the last
generation of a single simulation fileSummarizes a collection of simulation files, by producing a
data.frame
each row of which contains the parameters and the data from the last
generation of a single simulation file
summarize.sims(
simulations_path,
simulation_file_pattern = "sim_.*",
parameter_start_pattern = "^var",
parameter_end_pattern = NA,
data_start_pattern = "^generation",
data_end_pattern = "^\n",
sep = ";",
recursive = T,
callback_data = NULL,
callback_parameters = NULL
)
simulations_path |
the directory in which all the simulations are collected |
simulation_file_pattern |
a regular expression that matches the simulation files |
parameter_start_pattern |
a regular expression that matches the start of the parameters |
parameter_end_pattern |
a regular expression that matches the end
of the parameters. If parameters are at the end of the file anyway
one can just write |
data_start_pattern |
a regular expression that matches the start of the data output for each timestep or generation |
data_end_pattern |
a regular expression that matches the end of the data output for each timestep or generation |
sep |
data separators, e.g., |
recursive |
if |
callback_data |
function to perform additional
processing of the data (variables) section.
The function needs to accept a single argument |
callback_parameters |
function to perform additional processing of the parameters section.
The function needs to accept a single argument |
A data.frame
, each row of which contains the parameters and last line of
output of each simulation file and the corresponding file name in a column named
file
# say the current directory "."
# contains the following files:
# ├── file_x.csv
# ├── parameters.txt
# ├── sim_cue_integration_23_06_2020_095246_1.csv
# ├── sim_cue_integration_23_06_2020_095246_10.csv
# ├── sim_cue_integration_23_06_2020_095246_10_dist.csv
# ├── sim_cue_integration_23_06_2020_095246_11.csv
# ├── sim_cue_integration_23_06_2020_095246_11_dist.csv
#
# we need to obtain the files
# ├── sim_cue_integration_23_06_2020_095246_1.csv
# ├── sim_cue_integration_23_06_2020_095246_10.csv
# ├── sim_cue_integration_23_06_2020_095246_11.csv
#
# hence we provide a simulation_file_pattern = "sim_.*\d\.csv"
# which is a regular expression mating sim_ followed by a series
# of any characters .* finalized by a digit \d followed by a
# dot \. and csv
#
data <- summarize.sims(simulations_path="."
,simulation_file_pattern="sim_.*\\d\\.csv"
,parameter_start_pattern="^sigmoid"
,parameter_end_pattern="^sigmoid"
)
# collects the output from the files in the data.frame data
# sim_cue_integration_23_06_2020_095246_1.csv
# sim_cue_integration_23_06_2020_095246_10.csv
# sim_cue_integration_23_06_2020_095246_11.csv
# data will look like
str(data)
# 'data.frame': 150 obs. of 4 variables:
# generation: num 50000 500000 500000 ...
# var1: num 1 2 3 4 ...
# x: num 0.33 0.35 0.35...
# file: sim_cue_integration_23_06_2020_095246_1.csv ...
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.