Description Usage Arguments Details Value Examples
This function calls a number of internal functions to go from a unique
scenario identifier like "D1-E2-F3-M0-R4-cod"
and read the
corresponding input files (e.g. "M0-cod.txt"
) that have two columns:
the first column contains the argument names and the second column contains
the argument values. The two columns should be separated by a semicolon.
The output is then returned in a named list with the intention of passing
these to run_ss3sim
or ss3sim_base
.
1 2 | get_caseargs(folder, scenario, ext = ".txt", case_files = list(F = "F",
D = c("index", "lcomp", "agecomp")))
|
folder |
The folder to look for input files in. |
scenario |
A character object that has the cases separated by the "-"
delimiter. The combination of cases and stock ID is referred to as a
scenario. E.g. |
ext |
The file extension of the input files. Defaults to
|
case_files |
A named list that relates the case IDs (e.g. |
Let's start with an example scenario "D0-E1-F0-M0-R0-cod"
.
The single capital letters refer to case IDs. The numbers refer to the case
numbers. The last block of text (cod
) represents the stock ID (any
alphanumeric string of text will work) and is to help the user identify
different "stocks" (intended to represent different SS3 model setups).
The stock IDs should correspond to how the case files are named and the
case IDs should correspond to the cases described by the case_files
.
The case file names will correspond to the list values plus the stock ID.
For example list(D = c("index", "lcomp", "agecomp"))
combined with
the stock ID cod
means that the case D1
will refer to the
case files index-cod.txt, lcomp-cod.txt, agecomp-cod.txt
.
The case argument plain text files should have arguments in the first column that should be passed on to functions. The names should match exactly. The second column (delimited by a semicolon) should contain the values to be passed to those arguments. Multiple words should be enclosed in quotes.
You can use any simple R syntax to declare argument values. For example:
c(1, 2, 4)
, or seq(1, 100)
, or 1:100
, or
matrix()
, or NULL
. Character objects don't need to be quoted,
but can be if you'd like. However, be careful not to use the delimiter (set
up as a semicolon) anywhere else in the file besides to denote columns. You
can add comments after any #
symbol just like in R.
Internally, the functions evaluate in R any entries that have no
character values (e.g. 1:100
), or have an alpha-numeric character
followed by a (
. Anything that is character only or has character
mixed with numeric but doesn't have the regular expression
"[A-Za-z0-9]("
gets turned into a character argument. (NA
and
NULL
are special cases that are also passed on directly.)
A (nested) named list. The first level of the named list refers to
the case_files
. The second level of the named list refers to the
argument names (the first column in the input text files). The contents of
the list are the argument values themselves (the second column of the input
text files).
1 2 3 4 5 6 7 8 9 10 11 12 13 | # Find the example data folders:
case_folder <- system.file("extdata", "eg-cases", package =
"ss3sim")
# An example using the cases defined by default:
get_caseargs(case_folder, scenario = "D0-F0-cod")
# With a custom time-varying case for selectivity, which we'll call
# the S case. Here, we'll need to define which file the case S should
# read from ("S*-cod.txt"):
get_caseargs(case_folder, scenario = "D0-E0-F0-M0-R0-S0-cod",
case_files = list(E = "E", D = c("index", "lcomp", "agecomp"), F =
"F", M = "M", R = "retro", S = "S"))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.