Learn R Programming

bayesPop (version 5.2-2)

get.pop: Evaluation of Basic Components of Expressions

Description

Evaluates a basic component of an expression and results in a four-dimensional array.

Usage

get.pop(object, pop.pred, aggregation = NULL, observed = FALSE, ...)

Arguments

object
Character string giving the basic component of an expression (see pop.expressions).
pop.pred
Object of class bayesPop.prediction.
aggregation
If the basic component is to be evaluated on an aggregated prediction object, this argument gives the name of the aggregation (corresponds argument name in pop.aggregate). By default, the
observed
Logical. Determines if the evaluation uses observed data (TRUE) or predictions (FALSE).
...
Additional argument passed to the underlying functions. Currently, this is only used for a Population component and observed=FALSE. It can be either nr.traj giving the number of trajectories or logical typi

Value

  • Array of four dimensions (country x age x time x trajectory). See pop.expressions for more details.

Details

This function is rather an internal function used for evaluation after an expression is decomposed into basic components. However, it can be also used for debugging purposes, to obtain results from parts of an expression.

See Also

pop.expressions

Examples

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

# observed female of Netherlands by age; 1x21x13x1 array
popFNL <- get.pop("PNL_F{}", pred, observed=TRUE)

# observed migration for all countries in the prediction object,
# here 2 countries; 2x1x13x1 array
migAll <- get.pop("GXXX", pred, observed=TRUE)

# projection population for Ecuador with 3 trajectories; 
# 1x1x19x3 array
popEcu <- get.pop("P218", pred, observed=FALSE)

# Expression "PNL_F{} / PNL_M{}" evaluated on projections
# is internally replaced by
FtoM <- get.pop("PNL_F{}", pred) / get.pop("PNL_M{}", pred)

Run the code above in your browser using DataLab