lshtm-gigs / gigs

Convert between measurements and z-scores/percentiles for INTERGROWTH-21st and WHO Child Growth Standards, and classify growth patterns.
https://lshtm-gigs.github.io/gigs/
GNU General Public License v3.0
2 stars 0 forks source link

Better error and warning messages. #23

Closed simpar1471 closed 5 months ago

simpar1471 commented 5 months ago

Errors are currently unique and helpful, but not as much as possible.

For example consider this error for zero-length input:

ig_nbs_value2centile(y = numeric(), gest_days = 270, sex = "M", acronym = "ffmfga")

Output: Error: Variable 'y': Input had length 0, but must have length 1 or greater.

This is fine - we know which of our inputs is causing the error, and how this looks.

When we do this in the standard-specific function, we get the same error:

ig_nbs_ffmfga_value2centile(fat_free_mass_g = numeric(), gest_days = 270, sex = "M")

Output: Error: Variable 'y': Input had length 0, but must have length 1 or greater.

This tells us our y variable is the culprit, but the actual argument name is fatfree_mass_g, not y. This needs changing, probably through changes to how each standard-specific conversion function interfaces with the validate_ig_nbs()-style input checking functions.

simpar1471 commented 5 months ago

Currently low-priority whilst other features are worked on. Will return to this once time allows.

simpar1471 commented 5 months ago

Implementing this was not as bad as expected --> will be included in next minor version.