cohorts: Extracting and Plotting Cohort Data

View source: R/get_outputs.R

pop.cohorts.plotR Documentation

Extracting and Plotting Cohort Data


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


cohorts(pop.pred, country = NULL, expression = NULL, pi = c(80, 95))
pop.cohorts.plot(pop.pred, country = NULL, expression = NULL, cohorts = NULL, = 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", ...)



Object of class bayesPop.prediction.


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


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.


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


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.

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.


Number of column for the graphics device.


Logical controlling whether the legend should be drawn.


Position of the legend passed to the legend function.

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

Graphical parameters passed to the plot function.


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


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


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.


Hana Sevcikova

See Also

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


    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 <- cohorts(pred, expression="P528{}")
    pop.cohorts.plot(pred,, cohorts=c(1960, 1980, 2000, 2020))

bayesPop documentation built on Aug. 10, 2023, 1:10 a.m.