#' calculate_4proportions_list
#'
#' @param P,R,Z vectors of model output
#'
#' @return a list of the proportions in the order modern, trad, unmet, total_cpr
#'
calculate_4proportions_list <- function(P, R, Z){
modern = R*P
trad = (1-R)*P
unmet = (1-P)*Z
props <- list(one = modern,
two = trad,
three = unmet,
four = 1-(modern+trad+unmet))
}
#' calculate_4proportions_matrix
#'
#' @param P,R,Z vectors of model output
#' @return a matrix of the proportions with columns in the order modern, trad, unmet, total_cpr
#'
calculate_4proportions_matrix <- function(P, R, Z){
modern = R*P
trad = (1-R)*P
unmet = (1-P)*Z
cbind(modern,trad,unmet,1-(modern+trad+unmet))
}
#' calculate_3proportions_vec
#'
#' @param P,R,Z vectors of model output
#' @return a vector of transformed proportions in the order modern, trad, unmet, total_cpr
#'
calculate_3proportions_vec <- function(P, R, Z){
modern = R*P
trad = (1-R)*P
unmet = (1-P)*Z
c(modern,trad,unmet)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.