Skip to content

Commit

Permalink
Merge pull request #117 from nutriverse:dev
Browse files Browse the repository at this point in the history
update CITATION
  • Loading branch information
ernestguevarra authored Dec 19, 2024
2 parents cc176dd + f0d95b1 commit 1667b4b
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 44 deletions.
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export(calculate_dead)
export(calculate_default)
export(calculate_los)
export(calculate_los_median)
export(calculate_median_muac)
export(calculate_muac_median)
export(calculate_no_response)
export(calculate_performance)
export(calculate_rout)
Expand Down
26 changes: 23 additions & 3 deletions R/muac_at_admission.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
#' median mid-upper arm circumference with names from each level of `index`.
#'
#' @examples
#' calculate_median_muac(otp_beneficiaries$muac)
#' calculate_median_muac(otp_beneficiaries$muac, otp_beneficiaries$locality)
#' calculate_muac_median(otp_beneficiaries$muac)
#' calculate_muac_median(otp_beneficiaries$muac, otp_beneficiaries$locality)
#'
#' @export
#' @rdname calculate_muac
#'

calculate_median_muac <- function(muac, index = NULL, na_values = NULL) {
calculate_muac_median <- function(muac, index = NULL, na_values = NULL) {
if (!is.null(na_values)) {
muac <- ifelse(muac %in% na_values, NA_real_, muac)
}
Expand All @@ -38,3 +39,22 @@ calculate_median_muac <- function(muac, index = NULL, na_values = NULL) {

median_muac
}


calculate_muac_median_count <- function(muac, n, index = NULL) {
if (is.null(index)) {
Map(f = rep, x = muac, times = n) |>
unlist() |>
median(na.rm = TRUE)
} else {
split(data.frame(muac, n), f = index) |>
lapply(
FUN = function(x) Map(f = rep, x = x$muac, times = x$n) |> unlist()
) |>
lapply(FUN = median, na.rm = TRUE) |>
(\(x) do.call(rbind, x))() |>
(\(x) data.frame(
index = row.names(x), median_muac = x, row.names = NULL
))()
}
}
48 changes: 24 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,18 +133,18 @@ monitoring |>
which results in the following:

#> # A tibble: 72 × 7
#> State Year total_discharge cure_rate default_rate death_rate
#> <chr> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 Blue Nile 2016 9693 0.889 0.0906 0.0151
#> 2 Blue Nile 2017 10286 0.948 0.0399 0.00972
#> 3 Blue Nile 2018 8807 0.947 0.0404 0.00863
#> 4 Blue Nile 2019 9882 0.953 0.0366 0.00708
#> 5 Central Dar… 2016 13313 0.921 0.0440 0.0174
#> 6 Central Dar… 2017 18098 0.935 0.0421 0.00912
#> 7 Central Dar… 2018 17600 0.939 0.0364 0.00955
#> 8 Central Dar… 2019 18573 0.952 0.0260 0.00549
#> 9 East Darfur 2016 9895 0.929 0.0550 0.0104
#> 10 East Darfur 2017 12611 0.956 0.0327 0.00690
#> State Year total_discharge cure_rate default_rate death_rate
#> <chr> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 Blue Nile 2016 9693 0.889 0.0906 0.0151
#> 2 Blue Nile 2017 10286 0.948 0.0399 0.00972
#> 3 Blue Nile 2018 8807 0.947 0.0404 0.00863
#> 4 Blue Nile 2019 9882 0.953 0.0366 0.00708
#> 5 Central Da… 2016 13313 0.921 0.0440 0.0174
#> 6 Central Da… 2017 18098 0.935 0.0421 0.00912
#> 7 Central Da… 2018 17600 0.939 0.0364 0.00955
#> 8 Central Da… 2019 18573 0.952 0.0260 0.00549
#> 9 East Darfur 2016 9895 0.929 0.0550 0.0104
#> 10 East Darfur 2017 12611 0.956 0.0327 0.00690
#> # ℹ 62 more rows
#> # ℹ 1 more variable: non_response_rate <dbl>

Expand Down Expand Up @@ -256,25 +256,25 @@ citation provided by a call to the `citation` function as follows:

``` r
citation("squeacr")
#> To cite squeacr in publications use:
#> To cite sleacr in publications use:
#>
#> Myatt, Mark, Guevarra, Ernest, Fieschi, Lionella, Norris,
#> Allison, Guerrero, Saul, Schofield, Lilly, Jones, Daniel,
#> Emru, Ephrem, Sadler, Kate (2012). _Semi-Quantitative
#> Evaluation of Access and Coverage (SQUEAC)/Simplified Lot
#> Quality Assurance Sampling Evaluation of Access and Coverage
#> (SLEAC) Technical Reference_.
#> Mark Myatt, Ernest Guevarra, Lionella Fieschi, Allison
#> Norris, Saul Guerrero, Lilly Schofield, Daniel Jones, Ephrem
#> Emru, Kate Sadler (2012). _Semi-Quantitative Evaluation of
#> Access and Coverage (SQUEAC)/Simplified Lot Quality
#> Assurance Sampling Evaluation of Access and Coverage (SLEAC)
#> Technical Reference_. FHI 360/FANTA, Washington, DC.
#> <https://www.fantaproject.org/sites/default/files/resources/SQUEAC-SLEAC-Technical-Reference-Oct2012_0.pdf>.
#>
#> A BibTeX entry for LaTeX users is
#>
#> @Manual{,
#> location = {Washington, DC},
#> @Book{,
#> title = {Semi-Quantitative Evaluation of Access and Coverage ({SQUEAC})/Simplified Lot Quality Assurance Sampling Evaluation of Access and Coverage ({SLEAC}) Technical Reference},
#> url = {https://www.fantaproject.org/sites/default/files/resources/SQUEAC-SLEAC-Technical-Reference-Oct2012_0.pdf},
#> publisher = {FHI 360/FANTA},
#> author = {{Myatt} and {Mark} and {Guevarra} and {Ernest} and {Fieschi} and {Lionella} and {Norris} and {Allison} and {Guerrero} and {Saul} and {Schofield} and {Lilly} and {Jones} and {Daniel} and {Emru} and {Ephrem} and {Sadler} and {Kate}},
#> author = {{Mark Myatt} and {Ernest Guevarra} and {Lionella Fieschi} and {Allison Norris} and {Saul Guerrero} and {Lilly Schofield} and {Daniel Jones} and {Ephrem Emru} and {Kate Sadler}},
#> year = {2012},
#> publisher = {FHI 360/FANTA},
#> address = {Washington, DC},
#> url = {https://www.fantaproject.org/sites/default/files/resources/SQUEAC-SLEAC-Technical-Reference-Oct2012_0.pdf},
#> }
```

Expand Down
16 changes: 8 additions & 8 deletions inst/CITATION
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
bibentry(
bibtype = "Manual",
header = "To cite squeacr in publications use:",
location = "Washington, DC",
bibtype = "Book",
header = "To cite sleacr in publications use:",
title = "Semi-Quantitative Evaluation of Access and Coverage ({SQUEAC})/Simplified Lot Quality Assurance Sampling Evaluation of Access and Coverage ({SLEAC}) Technical Reference",
url = "https://www.fantaproject.org/sites/default/files/resources/SQUEAC-SLEAC-Technical-Reference-Oct2012_0.pdf",
publisher = "FHI 360/FANTA",
author = "Myatt, Mark and Guevarra, Ernest and Fieschi, Lionella and Norris, Allison and Guerrero, Saul and Schofield, Lilly and Jones, Daniel and Emru, Ephrem and Sadler, Kate",
year = "2012"
)
author = c(person("Mark Myatt"), person("Ernest Guevarra"), person("Lionella Fieschi"), person("Allison Norris"), person("Saul Guerrero"), person("Lilly Schofield"), person("Daniel Jones"), person("Ephrem Emru"), person("Kate Sadler")),
year = "2012",
publisher = "FHI 360/FANTA",
address = "Washington, DC",
url = "https://www.fantaproject.org/sites/default/files/resources/SQUEAC-SLEAC-Technical-Reference-Oct2012_0.pdf"
)
10 changes: 5 additions & 5 deletions man/calculate_median_muac.Rd → man/calculate_muac.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkgdown/_pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ reference:

- title: MUAC-at-admission
contents:
- calculate_median_muac
- calculate_muac_median

- title: Length of stay
contents:
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test-muac_at_admission.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Tests for calculate_median_muac function -------------------------------------

test_that("calculate_median_muac works as expected", {
expect_type(calculate_median_muac(otp_beneficiaries$muac), "double")
expect_type(calculate_muac_median(otp_beneficiaries$muac), "double")
expect_type(
calculate_median_muac(otp_beneficiaries$muac, otp_beneficiaries$locality),
calculate_muac_median(otp_beneficiaries$muac, otp_beneficiaries$locality),
"double"
)
})

0 comments on commit 1667b4b

Please sign in to comment.