verbal-autopsy-software / InterVA4

R package for InterVA-4 software
0 stars 4 forks source link

Enhancement: Determining top 3 likelihood #11

Open mboyas-mitre opened 5 years ago

mboyas-mitre commented 5 years ago

https://github.com/verbal-autopsy-software/InterVA4/blob/792fd94fcad1f143f55865e580a4ea0bc233e5bb/InterVA4_1.7/R/InterVA.R#L430-L444

This code is hard to follow and likely inefficient, given the separate steps. We believe it can be condensed to:

top3 <- sort(prob.temp, decreasing=T)[1:3]
top3[top3 < 0.5*(max(prob_B))] <- names(top3)[top3 < 0.5*(max(prob_B))] <- " "

And then the individual lik1-3 and cause1-3 variables can be created as top3[1] and names(top3)[1] (and so on), respectively. Or, if separate variables are not needed, the appropriate elements from the top3 vector can be directly referenced in the final output step.

richardli commented 5 years ago

thanks! on the todo list