Write XML files for a population to a directory
write_population_dir.Rd
This function creates a directory structure for a specified population and generates XML files containing data for newborns, population size, overall mortality, and disability. The files are saved in the population directory. The function only creates files for provided arguments and leaves other files as they are.
Usage
write_population_dir(
population_name,
sex_ratio,
starting_year,
newborns_df,
size_df,
mortality_df,
disability_df
)
Arguments
- population_name
A character string representing the name of the population. A directory will be created with this name if it does not already exist.
- sex_ratio
A numeric value representing the sex ratio of newborns (male to female ratio).
- starting_year
An integer representing the starting year of the newborns data.
- newborns_df
A data frame containing data for newborns, typically with columns for the year and the number of newborns.
- size_df
A data frame containing population size data, typically with columns for the year and population size.
- mortality_df
A data frame containing overall mortality data, typically with columns for the year and mortality rate.
- disability_df
A data frame containing overall disability data, typically with columns for the year and disability rate.
Details
The function creates a directory named after the population and generates the following XML files within it:
newborns.xml
: Contains data for newborns, including the sex ratio and number of newborns per year.size.xml
: Contains data for population size per year.overallmortality.xml
: Contains overall mortality rates per year.overalldisability.xml
: Contains overall disability rates per year.
The function uses helper functions to create XML documents for each type of data. These functions are expected to handle the formatting and structuring of the data into valid XML.
Examples
if (FALSE) { # \dontrun{
newborns <- data.frame(...)
size <- data.frame(...)
mortality <- data.frame(...)
disability <- data.frame(...)
create_population_dir("ExamplePopulation", 1.05, 2009, newborns, size, mortality, disability)
} # }