cohorts: Extracting and Plotting Cohort Data

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/get_outputs.R

Description

Extracts and plots population counts or results of expressions by cohorts.

Usage

1
2
3
4
5
6
cohorts(pop.pred, country = NULL, expression = NULL, pi = c(80, 95))
	
pop.cohorts.plot(pop.pred, country = NULL, expression = NULL, cohorts = NULL, 
    cohort.data = NULL, pi = c(80, 95), dev.ncol = 5, show.legend = TRUE, 
    legend.pos = "bottomleft", ann = par("ann"), add = FALSE, xlab = "", ylab = "",  
    main = NULL, xlim = NULL, ylim = NULL, col = "red", ...)

Arguments

pop.pred

Object of class bayesPop.prediction.

country

Name or numerical code of a country. If it is not given, expression must be specified.

expression

Expression defining the population measure to be plotted. For syntax see pop.expressions. It must be country-specific, i.e. “XXX” is not allowed, and it must contain curly braces, i.e. be age specific.

pi

Probability interval. It can be a single number or an array.

cohorts

Years of the cohorts to be plotted. By default, 10 future cohorts (starting from the last observed one) are used. It can be a single number or an array.

cohort.data

List with the cohort data obtained via the cohorts function. If it is not given, function cohorts is called internally, but by passing this argument the processing is faster.

dev.ncol

Number of column for the graphics device.

show.legend

Logical controlling whether the legend should be drawn.

legend.pos

Position of the legend passed to the legend function.

ann, xlab, ylab, main, xlim, ylim, col, ...

Graphical parameters passed to the plot function.

add

Logical specifying if the plot should be added to an existing graphics.

Details

pop.cohorts.plot plots all cohorts passed in the cohorts argument on the same scale of the y-axis.

Value

Function cohorts returns a list where each element corresponds to one cohort. Each cohort element is a matrix with columns corresponding to years and rows corresponding to the median (first row) and quantiles of the given probability intervals.

Author(s)

Hana Sevcikova

See Also

pop.trajectories.plot, pop.byage.plot, pop.expressions

Examples

1
2
3
4
5
6
7
8
9
    sim.dir <- file.path(find.package("bayesPop"), "ex-data", "Pop")
    pred <- get.pop.prediction(sim.dir)
    # Population cohorts
    pop.cohorts.plot(pred, "Netherlands")
    # plot specific cohorts using expression (must contain {})
    pop.cohorts.plot(pred, expression="P528{}", cohorts=c(1960, 1980, 2000, 2020))
    # the same as
    cohort.data <- cohorts(pred, expression="P528{}")
    pop.cohorts.plot(pred, cohort.data=cohort.data, cohorts=c(1960, 1980, 2000, 2020))

bayesPop documentation built on Oct. 30, 2019, 9:57 a.m.