#' This adds vaccination campaigns from the generated csv to the vaccination coverage.
#'
#' @param dndf A dataframe with the adm0, adm1 and adm2 locations of campaigns to be implemented.
#' @param pop1.adm2 The population 3d array.
#' @param vacc.cov The vaccination coverage 3d array.
#' @param year The year the vaccination campaign took place in.
#' @param country The ISO code of the vaccination campaign took place in.
#' @param adm1 The adm1 location the vaccination campaign took place in.
#' @param adm2 The adm2 location the vaccination campaign took place in.
#' @param doses The doses used in the vaccination campaign.
#' @param coverage The coverage of the vaccination campaign took place in.
#' @param agemin The minimum age targeted.
#' @param agemax The maximum age targeted.
#' @param skew The skew.
#' @examples
#' add.vacc.campaign(vacc.cov=campaigns,pop1.adm2=populationarray,year=2016,country="AGO",adm1="AGO1",adm2=NA,doses=50000,coverage=NA,agemin=10,agemax=50,skew=0)
#' @keywords internal
add.vacc.campaign = function(dndf,pop1.adm2,vacc.cov,year=y,country=NA,adm1=NA,adm2=NA,doses=0,coverage=NA,agemin=0,agemax=100,skew=0) {
if(!is.na(country)[1]) { x1 = which(dndf$adm0 %in% country)# match(country, dn1.0)
} else if(!is.na(adm1)[1]) { x1 = which(dndf$adm1 %in% adm1)# match(adm1, dn1.1)
} else if(!is.na(adm2)[1]) { x1 = which(dndf$adm2 %in% adm2)# match(adm2, dn1.2)
} else { stop("missing country/adm1/adm2 information.\n")
}
x2 = match(as.numeric(as.character(year)),1950:2050) # only put the vaccine in at the end of the year, so the population is covered for next year.
x3.min = agemin+1
x3.max = agemax+1
for(doot in 1:length(coverage)){
#Working out the coverage if over 1 or only dosese/targetpopulation supplied
if(is.na(coverage)[doot]) {
tot.pop = sum(pop1.adm2[x1,x2,x3.min:x3.max],na.rm=T)
coverage2 = min(1,doses[doot]/tot.pop,na.rm=TRUE)
} else {
if(coverage[doot]>1) coverage2 = coverage[doot]/100 # re-scale from percentage to proportion
coverage2=min(coverage[doot],1)
}
#Implementing vaccination
if(x3.min && x3.max == 1){
vacc.cov[x1,x2,x3.min:x3.max] = calc.new.coverage.vectorized(vacc.cov[x1,x2,x3.min:x3.max],coverage2,skew)
if(x2<dim(vacc.cov)[2]) for(y in (x2+1):min(dim(vacc.cov)[2],x2+100-agemin)) {
vacc.cov[x1,y,(agemin+1+y-x2):min((agemax+1+y-x2),101)] = calc.new.coverage.vectorized(vacc.cov[x1,y,(agemin+1+y-x2):min((agemax+1+y-x2),101)],coverage2,skew)
# vacc.cov[x1,y,(agemin+1+y-x2):min((agemax+1+y-x2),101)] = vacc.cov[x1,y,(agemin+1+y-x2):min((agemax+1+y-x2),101)] + (1-vacc.cov[x1,y,(agemin+1+y-x2):min((agemax+1+y-x2),101)])*vacc.cov[x1,x2,(agemin+1):min(agemax+1,101-y+x2)]
}
} else if(x2<dim(vacc.cov)[2]){
for(y in (x2):min(dim(vacc.cov)[2],x2+100-agemin)) {
# vacc.cov[x1[doot],y,(agemin+1+y-x2):min((agemax+1+y-x2),101)] = calc.new.coverage.vectorized(vacc.cov[x1[doot],y,(agemin+1+y-x2):min((agemax+1+y-x2),101)],coverage2,skew)
vacc.cov[x1[doot],y,(agemin+1+y-x2):min((agemax+1+y-x2),101)] = calc.new.coverage.vectorized(vacc.cov[x1[doot],y,(agemin+1+y-x2):min((agemax+1+y-x2),101)],coverage2,skew)
# vacc.cov[x1,y,(agemin+1+y-x2):min((agemax+1+y-x2),101)] = vacc.cov[x1,y,(agemin+1+y-x2):min((agemax+1+y-x2),101)] + (1-vacc.cov[x1,y,(agemin+1+y-x2):min((agemax+1+y-x2),101)])*vacc.cov[x1,x2,(agemin+1):min(agemax+1,101-y+x2)]
}
} else vacc.cov[x1[doot],x2,x3.min:x3.max] = calc.new.coverage.vectorized(vacc.cov[x1[doot],x2,x3.min:x3.max],coverage2,skew)
}
return(vacc.cov)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.