Most of my work is related to diagnostic tests for tuberculosis. As you can imagine, this is convenient for quickly evaluating and verifying the results of these tests. I wrote a function that does just that here (simplified for clarity). In short, it accepts numerical test results and produces the interpretation specified by the manufacturer.
This feature works well for me - I tested it against thousands of tests, and it is fast enough for everything I throw into it. However, I would like to associate it and a couple of similar functions with the package for wider use, and I would like to get some feedback from it before I do this:
The function depends on a big big loop wrapped around nested if-else functions. This is not particularly elegant, and fear for()certainly harms my trust in some (um), but it works. Is there a better approach to this? If so, is it better enough to require re-writing code that works?
The criteria in the above function are for interpreting a test in North America; the rest of the world adheres to several different standards. I would also like to have them. I am considering using a separate, non-exported function for each. Various data checks (excluded from the above list) would continue to live in the main function, which would then call the specified subfunction. Does that sound reasonable?
Any other suggestions or tips? Style, code organization - nothing at all.
I understand that I probably should just push this bird out of the nest, but I work mostly in a vacuum, and so I'm a little nervous. Any advice is appreciated.
Edit: if you missed the essence link, this is the function I'm talking about .
As requested, sample test data .
source
share