R/add_1940_1950.R

#' Adds the years 1940 to 1950 to the 2 dimensional dataframe of population "pop2d".
#' 
#' @param pop2d The 2 dimensional dataframe of population. 
#' 
#' @examples
#' add_1940_1950(pop2d)
#' @keywords internal

add_1940_1950 = function(pop2d){
  
  if(min(pop2d$year) != 1950)  stop("pop2d should start in 1950")
  
  for(y in 1949:1940) {
    pop1.early<-pop2d[pop2d$year==y+1,]
    pop1.early$year<-y
    pop2d<-rbind(pop1.early,pop2d)
  }
  
  return(pop2d)
}
arranhamlet/popvac_package documentation built on May 10, 2019, 1:48 p.m.