Skip to content

Commit

Permalink
Merge pull request #76 from nutriverse/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaszaba authored Nov 4, 2024
2 parents f16a66c + 12462fe commit 7ab1b2b
Show file tree
Hide file tree
Showing 110 changed files with 4,527 additions and 3,211 deletions.
4 changes: 3 additions & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
^ipccheckr\.Rproj$
^\.Rproj\.user$
^LICENSE\.md$
^README\.Rmd$
Expand All @@ -14,6 +13,9 @@
^README_files$
^mwana\.Rproj$
^vignettes/plausibility_files$
ˆvingettes/plausibility.html$
^vignettes/prevalence_files$
ˆvignettes/prevalence.html$
^vignettes/sample_size_files$
ˆvignettes/sample_size.html$
^CODE_OF_CONDUCT\.md$
4 changes: 2 additions & 2 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
branches: [main, dev]
pull_request:
branches: [main, master]
branches: [main, dev]

name: R-CMD-check

Expand Down
9 changes: 5 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: ipccheckr
Package: mwana
Title: Utilities for Analysing Children's Nutritional Status
Version: 0.0.0.9000
Version: 0.1.0.9000
Authors@R: c(
person("Tomás", "Zaba", , "[email protected]", role = c("aut", "cre", "cph"),
comment = c(ORCID = "0000-0002-7079-3574")),
Expand All @@ -12,7 +12,7 @@ Description: A streamlined and comprehensive implementation of the Standardized
Monitoring and Assessment of Relief and Transition (SMART) Methodology
<https://smartmethodology.org/> guidelines for data quality checks and
prevalence estimation, with enhanced programmable process particularly when
handling large multiple datasets.
handling multiple area datasets.
License: GPL (>= 3)
URL: https://github.com/nutriverse/mwana, https://nutriverse.io/mwana
Imports:
Expand All @@ -24,7 +24,8 @@ Imports:
srvyr,
stats,
zscorer,
tibble
tibble,
methods
Suggests:
knitr,
rmarkdown,
Expand Down
30 changes: 17 additions & 13 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# Generated by roxygen2: do not edit by hand

export(age_ratio_test)
export(check_plausibility_mfaz)
export(check_plausibility_muac)
export(check_plausibility_wfhz)
export(check_sample_size)
export(classify_overall_quality)
export(compute_combined_prevalence)
export(compute_muac_prevalence)
export(compute_quality_score)
export(compute_wfhz_prevalence)
export(define_wasting)
export(flag_outliers)
export(generate_pretty_table_mfaz)
export(generate_pretty_table_muac)
export(generate_pretty_table_wfhz)
export(process_age)
export(process_muac_data)
export(process_wfhz_data)
export(get_age_months)
export(mw_check_ipcamn_ssreq)
export(mw_neat_output_mfaz)
export(mw_neat_output_muac)
export(mw_neat_output_wfhz)
export(mw_plausibility_check_mfaz)
export(mw_plausibility_check_muac)
export(mw_plausibility_check_wfhz)
export(mw_stattest_ageratio)
export(mw_wrangle_age)
export(mw_wrangle_muac)
export(mw_wrangle_wfhz)
export(recode_muac)
export(remove_flags)
importFrom(dplyr,across)
importFrom(dplyr,case_when)
importFrom(dplyr,ends_with)
Expand All @@ -31,12 +31,15 @@ importFrom(dplyr,n_distinct)
importFrom(dplyr,rename)
importFrom(dplyr,summarise)
importFrom(lubridate,ymd)
importFrom(methods,is)
importFrom(nipnTK,ageRatioTest)
importFrom(nipnTK,digitPreference)
importFrom(nipnTK,greensIndex)
importFrom(nipnTK,sexRatioTest)
importFrom(nipnTK,skewKurt)
importFrom(rlang,.data)
importFrom(rlang,enquo)
importFrom(rlang,eval_tidy)
importFrom(rlang,sym)
importFrom(scales,label_percent)
importFrom(scales,label_pvalue)
Expand All @@ -47,4 +50,5 @@ importFrom(stats,pnorm)
importFrom(stats,prop.test)
importFrom(stats,sd)
importFrom(stats,setNames)
importFrom(tibble,as_tibble)
importFrom(zscorer,addWGSR)
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# ipccheckr v0.0.0.9000 (development version)
# mwana v0.0.0.9000 (development version)

* Initial pre-release version for alpha-testing.
162 changes: 0 additions & 162 deletions R/age.R

This file was deleted.

72 changes: 72 additions & 0 deletions R/ipc_amn_check.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#'
#' Check whether IPC Acute Malnutrition (IPC AMN) sample size requirements were met
#'
#' @description
#' Evidence on the prevalence of acute malnutrition used in the IPC AMN
#' can come from different sources: surveys, screenings or community-based
#' surveillance system. The IPC set minimum sample size requirements
#' for each source. This function helps in verifying whether the requirements
#' were met or not depending on the source.
#'
#' @param df A dataset object of class `data.frame` to check.
#'
#' @param cluster A vector of class `integer` or `character` of unique cluster or
#' screening or sentinel site IDs. If a `character` vector, ensure that names are
#' correct and each name represents one location for accurate counts. If the class
#' does not match the above expected type, the function will stop execution and
#' return an error message indicating the type of mismatch.
#'
#' @param .source The source of evidence. A choice between "survey" for
#' representative survey data at the area of analysis; "screening" for
#' screening data; "ssite" for community-based sentinel site data.
#'
#' @returns A summary table of class `data.frame`, of length 3 and width 1, for
#' the check results. `n_clusters` is for the total number of unique clusters or
#' screening or site IDs; `n_obs` for the correspondent total number of children
#' in the dataset; and `meet_ipc` for whether the IPC AMN requirements were met.
#'
#' @references
#' IPC Global Partners. 2021. *Integrated Food Security Phase Classification*
#' *Technical Manual Version 3.1.Evidence and Standards for Better Food Security*
#' *and Nutrition Decisions*. Rome. Available at:
#' <https://www.ipcinfo.org/ipcinfo-website/resources/ipc-manual/en/>.
#'
#' @examples
#' mw_check_ipcamn_ssreq(
#' df = anthro.01,
#' cluster = cluster,
#' .source = "survey"
#' )
#'
#' @export
#'
mw_check_ipcamn_ssreq <- function(df,
cluster,
.source = c("survey", "screening", "ssite")) {
## Difuse and evaluate arguments ----
cluster <- eval_tidy(enquo(cluster), df)

## Enforce the options in `.source` ----
.source <- match.arg(.source)

## Enforce the class of `cluster` ----
if (!(class(cluster) %in% c("integer", "character"))) {
stop(
"`cluster` must be of class `integer` or `character`; not ", shQuote(class(cluster)), ". Please try again."
)
}

## Summarize ----
df <- df |>
summarise(
n_clusters = n_distinct({{ cluster }}),
n_obs = n(),
meet_ipc = case_when(
.source == "survey" & n_clusters >= 25 ~ "yes",
.source == "screening" & n_clusters >= 3 & n_obs >= 600 ~ "yes",
.source == "ssite" & n_clusters >= 5 & n_obs >= 200 ~ "yes",
.default = "no"
)
)
as_tibble(df)
}
8 changes: 6 additions & 2 deletions R/ipccheckr-package.R → R/mwana-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@

## usethis namespace: start
#' @importFrom dplyr across case_when group_by mutate n n_distinct rename summarise
#' @importFrom dplyr ends_with everything filter
#' @importFrom dplyr ends_with everything filter mutate
#' @importFrom dplyr group_by
#' @importFrom dplyr summarise
#' @importFrom lubridate ymd
#' @importFrom methods is
#' @importFrom nipnTK ageRatioTest digitPreference sexRatioTest skewKurt greensIndex
#' @importFrom rlang .data sym
#' @importFrom rlang .data sym enquo eval_tidy
#' @importFrom scales label_percent label_pvalue
#' @importFrom srvyr as_survey_design survey_mean
#' @importFrom stats na.omit prop.test sd pnorm setNames
#' @importFrom tibble as_tibble
#' @importFrom zscorer addWGSR
## usethis namespace: end
NULL
Loading

0 comments on commit 7ab1b2b

Please sign in to comment.