Learn R Programming

SEERaBomb (version 2016.1)

fillPYM: Fills age-year person year (PY) matrix

Description

This internal function converts a matrix with lots of individual PY contributions and starting ages and years as rows, into a population-level PY histrogram matrix of (1-year age)x(1-year year) resolution bins. The output matrix is more square-like (currently at 40 calendar years by 126 age years) than the tall dataframe-like input matrix.

Usage

fillPYM(PYin,PYM)

Arguments

PYin
Tall input matrix where rows hold individual PY at risk, year and starting (left) ages ageL.
PYM
Output PY matrix with age and calendar year rows and columns at single year resolution.

Value

function. After the call, it will be filled; this function uses pointers in Rcpp C++ code.

Examples

Run this code
  yrs=1973:1990
  ages=0.5:70.5
  PYM=matrix(0,ncol=length(yrs),nrow=length(ages))
  colnames(PYM)=yrs
  rownames(PYM)=ages
(PYin=structure(c(3.5, 11.25,5.2, 51.5, 58.5,0.75, 1974, 1976,1978),.Dim = c(3L,3L), 
                  .Dimnames=list(c("1","2","3"),c("py", "ageL", "year"))))
fillPYM(PYin, PYM)

Run the code above in your browser using DataLab