tidy_pp: Create a Tidy Data Frame from Population Projection Matrix...

Description Usage Arguments Value Examples

Description

Gathers a population projection matrix and converts it into a tidy data frame with labels for projection year, age and gender groups.

Usage

1
2
3
tidy_pp(proj_mat = NULL, year0 = 0, steps = NULL, age_lab = NULL,
  gender_lab = c("Female", "Male"), year_col = "Year", age_col = "Age",
  gender_col = "Gender", pop_col = "Population", denom = 1000)

Arguments

proj_mat

Matrix of population projection results. Columns represent projection years, rows represent age and gender groups. If composed of both male and female groups, female population projections should be in the top half of the matrix.

year0

Numeric value for the base year of the population projection.

steps

Numeric value for step size of the population projection.

age_lab

Vector containing a character string of age group labels. The length of age_lab multiplied by the length of gender_lab must be equal to the number of rows in proj_mat

gender_lab

Vector containing a character string of gender group labels. The length of age_lab multiplied by the length of gender_lab must be equal to the number of rows in proj_mat

year_col

Character string for the name of the year labels column.

age_col

Character string for the name of the age labels column.

gender_col

Character string for the name of the gender labels column.

pop_col

Character string for the name of the projected population counts column.

denom

Numeric value of a demominator to divide the population size of each age-gender group by.

Value

A tibble containing four columns. The first three contain information on the year, age and gender of the projection population. The fourth contain information in the projected population sizes or each year-age-gender combination.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
df0 <- sweden1993

# matrix output
pp <- fccp_closed0(n = 5, x = df0$x, p = 5, Nx = df0$Nx_f,
                   sx = df0$sx_f, fx = df0$fx, sn = df0$Lx_f[1]/(5*100000),
                   tidy_output = FALSE)
pp

tidy_pp(proj_mat = pp, year0 = 1993, steps = 5,
        age_lab = df0$age, gender_lab = "Female")

gjabel/demoproj documentation built on May 17, 2019, 6:01 a.m.