verbal-autopsy-software / InSilicoVA

R package for InSilicoVA framework
3 stars 6 forks source link

Error with edge case: InSilicoVA args: datacheck=FALSE and subpop provided #29

Open jarathomas opened 1 year ago

jarathomas commented 1 year ago

The following (very unlikely) code produces an error because the internal variable subpop_order_list never gets defined:

library(openVA)
data(RandomVA5)
insilico(RandomVA5, data.type="WHO2016", datacheck=FALSE, subpop="i019a")

The error message is:

Error in removeExtV5(data, prob.orig, csmf.orig, isNumeric, subpop, subpop_order_list,  : 
  object 'subpop_order_list' not found

A simple hacky patch might be to include the following after line 954 in insilico_core.r

if (is.null(subpop)) {
  subpop_order_list <- NULL
} else {
  subpop_order_list <- sort(unique(subpop))
}

More may be needed if the customization.dev argument is TRUE