Description Usage Arguments Details Value Author(s) See Also Examples
fread.msproj
is a convenience function that can be used to read all the files generated by the state.space
function and bring it into the list form required by msproj
.
1 | fread.msproj(data.dir = "input_data/", model.patt = NULL)
|
data.dir |
The path to the directory that contains the data sets. Defaults to the subdirectory "input_data/" of the current working directory. If the user wants to use a different directory, he has to specify the whole path instead. |
model.patt |
The name of the scenario as contained in the names of all relevant data sets. |
Using this function requires that all the relevant files (state space, variable definitions, and one or two migration files) are contained in the same folder and show the same pattern in their names. This is guaranteed if the state.space
function was used to create these files and the user didn't make any manual changes. If a user really wants to rename the files, it is only possible to do this for the parts specifying the country and the scenario, respectively, but the patterns "_mig_dom" (for domestic migration), "_mig_int" (for international migration), "_state_space" (for the state space), and "_var_def" (for the variable definitions) must be kept in the naming!
fread.msproj
returns a list consisting of four elements if domestic migration is considered or three elements otherwise:
domestic migration |
A data frame containing the rates or flows of domestic migration for each possible combination of origin and destination. Only created when domestic migration is part of the model. |
international migration |
A data frame containing the flows and rates of international migration for each possible combination of origin and destination. |
state.space |
A data frame containing the state space itself. It contains all the data needed to run the simulation (population, fertility, mortality etc.) for all possible combinations of sex, age, region etc. There is only one exception: Migration data has a different structure and thus, is written into one or two separate list elements. |
variable.definitions |
A two-dimensional vector containing an overview of the variables used in the simulation and the values they may take. This information is partly used in the simulation itself, but also can be seen as metadata that provides useful information about the specific simulation settings. |
Every list element represents one of the files that have been read. Hence, where state.space
split up the list that it created and saved the list elements as single files to a certain directory, fread.msproj
does just the opposite. When comparing the lists, the only difference is the matrix of education transitions that is created by state.space
, but not saved to a file, and thus, not included in the list created by fread.msproj
.
Marcus Wurzer
The function is based on the fread
function included in the data table package.
1 2 3 4 5 6 7 8 9 10 | ## Creating a state space for India and giving this scenario a name:
st.sp <- state.space(country = "India", scen = "test_scenario")
str(st.sp)
## Reading the files that have been saved to the current
## working directory automatically. The pattern consists of
## the country name and the name of the scenario, separated
## by an underscore:
datasets <- fread.msproj(model.patt = "India_test_scenario")
str(datasets)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.