Add functions to extract prep coverage and prep method mix#1
Conversation
| "MSM: med risk" = 8, | ||
| "MSM: high risk" = 9, | ||
| "MSM: PWID" = 10), | ||
|
|
There was a problem hiding this comment.
I like the assigned constants, I didn't know R supported that. risk.groups is duplicative of hv.pop.ext. I would prefer to just define one or the other, and would prefer using hv.pop.ext to avoid changing other functions.
There was a problem hiding this comment.
Thanks, I'll add in the encoding on hiv.pop.ext. Assuming All = 0 and Not at risk = 1 ?
There was a problem hiding this comment.
Yes, using All=0 and Not at risk=1 should be good.
| #' @param final.year Final year of the projection. | ||
| #' @return A data frame. | ||
| #' @export | ||
| rn.prep.coverage= function(rn.raw, direction="wide", first.year, final.year) { |
There was a problem hiding this comment.
Please rename to rn.inputs.prep.coverage for consistency with other methods.
| dat <- dat |> dplyr::select(sex, risk_group, dplyr::everything()) | ||
|
|
||
| if (direction=="long") { | ||
| dat = reshape2::melt(raw, id.vars=c("sex", "risk_group", "prep_method"), |
There was a problem hiding this comment.
Not for now, but if we do move to tidyr we can replace all these melt calls with tidyr::pivot_longer and get rid of the reshape2 dependency.
There was a problem hiding this comment.
I can replace tidyr throughout?
There was a problem hiding this comment.
Let's keep reshape2 here. My comment about tidyr was based on a misunderstanding. I thought the |> operator was defined in tidyr. Since that operator has been in base I don't think we need to add a dependency on tidyr or go through the testing process that replacing reshape2::melt would entail.
Added two new function to extract PrEP coverage and PrEP method mix from the Resource Needs module:
rn.prep.coverage()- extracts PrEP coveragern.prep.method.mix()- extracts PrEP method mixstrata.labels- added RN risk group and PrEP methods with corresponding numerical encoding