Reads 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)

Arguments

file

Name of the .csv file from which the population data are to be read. If it does not contain an absolute path, the file name is relative to the current working directory.

Value

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.

Details

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

See also

popim_population() for details of the S3 class, and utils::read.csv() which handles the reading of the .csv file.

Author

Tini Garske

Examples

filename <- system.file("extdata", "pop_sample.csv", package = "popim")
pop <- read_popim_pop(file = filename)