Repository navigation
App: move the LR calculators out of mispitools_app() - #40
Merged
Merged
Conversation
calc_lr_sex, calc_lr_age and calc_lr_hair were defined inside mispitools_app(), so they could only be reached by launching the app. They now live in R/app_helpers.R as internal functions (app_lr_sex, app_lr_age, app_lr_hair) with the same bodies, and have unit tests. Also adds a testServer test for the individual and combine tabs, and Toys/Ibrahim/app_snapshot.R, which records the displayed values over a grid of 355 inputs. The snapshot is identical before and after this change.
Owner
|
Cool! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First step of making the Shiny app testable.
calc_lr_sex,calc_lr_ageandcalc_lr_hairwere defined insidemispitools_app(), so there was no way to call them without launching the app. They are now in R/app_helpers.R as internal functions (app_lr_sex,app_lr_age,app_lr_hair). The bodies are copied as they were, I only renamed them so they don't get confused with the exportedlr_*()functions.Tests:
shiny::testServer(), so no browser is needed, and checks what the individual and combine tabs displayTo check the displayed numbers stay the same I wrote Toys/Ibrahim/app_snapshot.R. It records every output of the individual and combine tabs over 355 input combinations. The script is only on this branch, so copy it out of the repo first and run it from the repo root on each side:
Something that looks wrong in the age panel, R/app_unified.R:1091-1097 (the
indiv_formulaoutput). The LR is computed with the interval clamped to [1, 80], but the formula text uses the unclamped interval. With MP age 78 +/- 6, error 0.05:So the numbers on the screen don't give the LR shown under them. I left it as it is in this PR so the refactor stays a pure move, happy to fix it next.
Also a small one: in
calc_lr_agethe cap at 0.999 is never reached, because after clamping the widest interval is 79/80.Next steps would be
build_cpt_pop/build_cpt_mp, then the distribution, metrics and ROC functions.