Learn R Programming

bayesPop (version 4.2-2)

write.pop.projection.summary: Writing Projection Summary Files

Description

The function creates ASCII files containing projection summaries, such as the median, the lower and upper bound of the 80 and 90% probability intervals, respectively.

Usage

write.pop.projection.summary(pop.pred, what = NULL, expression = NULL, 
    output.dir = NULL, ...)

Arguments

pop.pred
Object of class bayesPop.prediction.
what
A character vector specifying what kind of projection to write. Total population is specified by pop. Vital events are specified by births, deaths, sr (survival rate) and fertilit
expression
Expression defining the measure to be written. If it is not NULL, argument what is ignored. For expression syntax see pop.expressions. The country components of the express
output.dir
Directory in which the resulting files will be stored. If NULL pop.pred$output.directory is used.
...
These are arguments used if expression is given: file.suffix defines the file suffix; expression.label (defaults to the expression) is put as the first line in the resulting file; logical include.observed

Details

There is one file created per value of what, or expression, called projection_summary_suffix.csv, where suffix is either what or alias of the expression. It is a comma-separated table with the following columns:
  • country_name: country name
  • country_code: country code
  • variant: name of the variant, such asmedian,lower 80,upper 80,lower 95,upper 95
  • period1: e.g.2005-2010: Given population measure for the first time period
  • period2: e.g.2010-2015: Given population measure for the second time period
  • ...further time period columns
If expression is given, the full expression is written as the first line of the file starting with #. The file contains one line per country, and possibly sex and age.

See Also

pop.predict, pop.map, pop.expressions

Examples

Run this code
outdir <- tempfile()
dir.create(outdir)
sim.dir <- file.path(find.package("bayesPop"), "ex-data", "Pop")
pred <- get.pop.prediction(sim.dir=sim.dir, write.to.cache=FALSE)

# proportion of 65+ years old to the whole population
write.pop.projection.summary(pred, expression="PXXX[14:27] / PXXX", file.suffix='age65plus', 
    output.dir=outdir, include.observed=TRUE, decimal=2)
    
# various measures
write.pop.projection.summary(pred, what=c('pop', 'popsexage', 'popsex'),
    output.dir=outdir)

unlink(outdir, recursive=TRUE)

Run the code above in your browser using DataLab