Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-factor mw_neat_output_mfaz() to allow multiple grouping variables #153

Open
tomaszaba opened this issue Mar 20, 2025 · 0 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@tomaszaba
Copy link
Collaborator

As of now, when users request {mwana} plausibility check neat functions to return outputs grouped by say "province" and then by "district", it does not respond adequately to:

Without colling mw_neat_output_mfaz() it work OK.

> anthro.02 |> group_by(province, strata) |> mw_plausibility_check_mfaz(sex = sex, muac = muac, age = age, flags = flag_mfaz)
# A tibble: 4 × 19
  province strata     n flagged flagged_class sex_ratio sex_ratio_class age_ratio age_ratio_class   dps dps_class      sd sd_class     skew
  <chr>    <chr>  <int>   <dbl> <fct>             <dbl> <chr>               <dbl> <chr>           <dbl> <chr>       <dbl> <chr>       <dbl>
1 Nampula  Rural    472 0.00424 Excellent         0.490 Excellent           0.410 Excellent         100 Problematic 0.895 Good     -0.113  
2 Nampula  Urban    614 0.0130  Good              0.493 Excellent           0.241 Excellent         100 Problematic 0.989 Excelle-0.364  
3 Zambezia Rural    368 0.0109  Good              0.566 Excellent           0.449 Excellent         100 Problematic 0.988 Excelle0.00407
4 Zambezia Urban    813 0.00738 Excellent         1     Excellent           0.391 Excellent         100 Problematic 0.940 Excelle-0.0430 
# ℹ 5 more variables: skew_class <fct>, kurt <dbl>, kurt_class <fct>, quality_score <dbl>, quality_class <fct>

But once called, the output table gets distorted.

anthro.02 |> group_by(province, strata) |> mw_plausibility_check_mfaz(sex = sex, muac = muac, age = age, flags = flag_mfaz) |> mw_neat_output_mfaz()
# A tibble: 4 × 19
  `Total children` `Flagged data (%)` `Class. of flagged data` `Sex ratio (p)` `Class. of sex ratio` `Age ratio (p)` `Class. of age ratio`
  <chr>            <chr>                                 <int> <chr>           <fct>                 <chr>           <chr>                
1 Nampula          Rural                                   472 0.4%            Excellent             0.490           Excellent            
2 Nampula          Urban                                   614 1.3%            Good                  0.493           Excellent            
3 Zambezia         Rural                                   368 1.1%            Good                  0.566           Excellent            
4 Zambezia         Urban                                   813 0.7%            Excellent             >0.999          Excellent            
# ℹ 12 more variables: `DPS (#)` <chr>, `Class. of DPS` <chr>, `Standard Dev* (#)` <dbl>, `Class. of standard dev` <chr>,
#   `Skewness* (#)` <dbl>, `Class. of skewness` <chr>, `Kurtosis* (#)` <dbl>, `Class. of kurtosis` <fct>, `Overall score` <dbl>,
#   `Overall quality` <fct>, `` <dbl>, `` <dbl>

Here, values under column "strata" get filled under "n" overriding "n"'s.

Task

Fix mw_neat_output_mfaz()

@tomaszaba tomaszaba added the bug Something isn't working label Mar 20, 2025
@tomaszaba tomaszaba self-assigned this Mar 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant