collate.census: Combine together HexSim census outputs across iterations.

Description Usage Arguments Details Value

View source: R/HexSimR.R

Description

Combine together HexSim census outputs across iterations. If the scenarios have multiple census events, all census files are processed (separately). Mean values are reported in the final file which is located in Results/scenario_name folder and returned as a list.

Usage

1
2
3
4
5
6
7
8
collate.census(
  path.results = NULL,
  scenarios = "all",
  start = "min",
  end = "max",
  keep.zeros = TRUE,
  verbose = FALSE
)

Arguments

path.results

The path to the 'Results' folder

scenarios

A character vector with the scenarios to be processed or "all"

start

The first time step to be included

end

The last time step to be included

keep.zeros

Whether zeros are retained in the mean calculations (TRUE, default), or are excluded (FALSE)

verbose

Should progress be printed in the console? Default: FALSE

Details

If there are several scenarios and scenarios="all" (default), all scenarios are processed, otherwise it is possible to select a subset of scenarios using a character vector, e.g. scenarios=c("scen1", "scen2").

If path.results=NULL an interactive dialog box is used to select the path where the results are located

start controls the first time step that should be considered in each iteration. This is intended to be used when the user wants to discard the first part of the simulations, for example because the model needs to reach a steady-state.

end controls the last time step that should be considered in each iteration. This is typically the last time step the simulations were set for, or it can be used to discard the time steps after a certain point. Note that if the population goes extinct, HexSim may stop recording data after the time step in which the population went extinct, hence the last time step may be different across iteration. Explicitly setting end is particularly important in this situation to ensure correct mean and sd calculations. collate.census will fill in the data with "0" if the population goes extinct before end when the latter is a number.

The default setting (i.e. end="max") is for convenience and to ensure back-compatibility, but its use is not recommended. When end="max" collate.census will use the last time step of each replicate as end point, nut, if the iterations have different number of time steps, the mean and sd calculations will be a mixture between the extant and all populations (across all iterations, see below).

keep.zeros is a logical (TRUE, default, or FALSE) and indicates whether the zero-values should be used in the mean and sd calculations. If not, the zeros are stripped out before calculations. This could make sense, for example, when the trait (or other variables) being considered indicates the population size and the user wants to consider only extent populations (i.e. ignore extinct populations). When keep.zeros=TRUE an "all" suffix is appended to the file name, otherwise, "extant" is used.

Note, when there is a large number of files, this function may be memory hungry

Value

A list with three elements: the combined data, the mean and standard deviation. Each of these elements is in itself a list with each scenario as a element. Nested within the scenarios is a list with each census file. An xls file is also saved with the descriptive statistics and a .rda file is saved with the combined data


carlopacioni/HexSimR documentation built on Nov. 28, 2020, 4:12 p.m.