pop.trajectories.plot}, {pop.trajectories.plotAll}, {pop.trajectories.table}, {pop.byage.plot}, {pop.byage.table}, {pop.map}, {pop.map.gvis}, {write.pop.projection.summary}.expression which should define a population measure, i.e. a quantity that can be computed from population projections, observed population data or vital events. Such expression is a collection of basic components connected via usual arithmetic operators, such as +, -, *, /, ^, %%, %/%, and combined using parentheses. In addition, standard R functions or predefined functions (see below) can be used within expressions.A basic component is a character string constituted of four parts, two of which are optional. They must be in the following order:
pop.predictkeep.vital.events=TRUE.
LOCATIONSage.index01(...) and age.index05(...) (see below) to define the right indices.Examples of basic components are
When the expression is evaluated on a prediction object, each basic component is substituted by an array of four dimensions:
Depending on the context from which the expression is called, the trajectory dimension of the result of the expression can be reduced by computing given quantiles, and if only one country is evaluated, the first dimension is removed. In addition, with an exception of functions {pop.byage.plot}, {pop.byage.table}, the expression should be constructed in a way that the age dimension is eliminated, for example by using the apply function or one of the pre-defined functions described below. When using within {pop.byage.plot} or {pop.byage.table}, the expression MUST include curly braces.
gmedian(f, cat)
It gives a median for grouped data with frequenciesfand categoriescat. This function is to be used in combination withapplyorpop.apply(see below) along the age dimension. For example,
pop.applybelow for a simplified version.)gmean(f, cat)
Works likegmedianbut gives the grouped mean.age.func(data, fun="*")
This function appliesfuntodataand the corresponding age. The default case would multiply data by the corresponding age. Asgmedian, it is to be used in combination withapplyorpop.apply.drop.age(data)
Drops the age dimension of the data. For example, if two basic components are combined where one is used within theapplyfunction, the other will need to change its dimension in order to have conformable arrays. For example,
pop.applybelow for a simplified version.)pop.apply(data, fun, ...)
Applies functionfunto the age dimension ofdataand converts the result into the same format as returned by a basic component. This allows combining theapplyfunction with other basic components without having to modify their dimensions. For example,
age.index01(end)
Can be used with indicatorsend.age.index05(end)
Returns an array of age group indices starting with group 0-4, 5-9 until the age group corresponding to indexend.[object Object],[object Object]
pop.trajectories.plot, pop.map, {write.pop.projection.summary}.
# median child-bearing age of Netherlands and all countries - trajecotries pop.trajectories.plot(pred, nr.traj=50, expression="pop.apply(P528_F{4:10}, gmedian, cats= seq(15, by=5, length=8))") pop.trajectories.plotAll(pred, nr.traj=50, expression="pop.apply(PXXX_F{4:10}, gmedian, cats= seq(15, by=5, length=8))")
# mean child-bearing age of Netherlands - table pop.trajectories.table(pred, expression="pop.apply(age.func(P528_F{4:10}), fun=sum) / P528_F[4:10]")
# migration per capita by age pop.byage.plot(pred, expression="GNL{} / PNL{}", year=2000)
# potential support ratio - map pop.map(pred, expression="PXXX[5:13] / PXXX[14:27]")
# proportion of 0-4 years old to whole population - export to an ASCII file dir <- tempfile() write.pop.projection.summary(pred, expression="PXXX[1] / PXXX", output.dir=dir) unlink(dir)
# These are vital events only available if keep.vital.events=TRUE in pop.predict # log female mortality rate by age for Netherlands in 2050, including 0-1 and 1-4 age groups pop.byage.plot(pred, expression="log(MNL_F{age.index01(27)})", year=2050)
# trajectories of male 1q0 and table of 5q0 for Netherlands
pop.trajectories.plot(pred, expression="QNLD_M[-1]")
pop.trajectories.table(pred, expression="QNLD_M[1]")