verbal-autopsy-software / InSilicoVA

R package for InSilicoVA framework
3 stars 6 forks source link

Enhancement: Perform argument checking up front #19

Closed mjutras-mitre closed 4 years ago

mjutras-mitre commented 5 years ago

The data.type parameter to the insilico function is a character vector of candidate values. It would make sense to do some argument checking at this point to ensure a correct type is used. What happens now is, for an erroneous type such as "WHO2020", the error is not detected until line 883 in insilico_core.r. For data.type = c("WHO2012","WHO2016"), a slew of errors and warning messages occur. This could be prevented by checking right away that the data.type is valid with code such as the following.

if(!missing(data.type) & length(data.type)>1) stop("Only one 'type' allowed.") data.type <- match.arg(data.type)

https://github.com/verbal-autopsy-software/InSilicoVA/blob/7f770ac7ab8d82c1b9de25debc7e734f06273df8/InSilicoVA/R/insilico_standard.r#L349