read_popim_pop.RdReads a population data from a .csv file, checks if
the data fulfils the requirements for a popim_population
object, and if so returns this object.
read_popim_pop(file)An object of class popim_population, a dataframe with one row
per birth cohort/year/region, with columns region, year,
age, cohort, immunity, pop_size.
The requirements are that the data contain the columns region,
age, year which will be coerced to character, integer,
integer. Columns pop_size and immunity are optional; they will
be coerced to numeric, and if missing will be initialised to 0 and
NA, respectively be set to NA and 0, respectively. Any additional
columns will be retained in the popim_population object.
Limitations for values:
age must be non-negative integer
immunity must be between 0 and 1 (inclusive)
pop_size must be non-negative
popim_population() for details of the S3 class, and
utils::read.csv() which handles the reading of the .csv
file.
filename <- system.file("extdata", "pop_sample.csv", package = "popim")
pop <- read_popim_pop(file = filename)