Skip to content

Commit

Permalink
Merge pull request #214 from R4EPI/znk-hide-unused-functions
Browse files Browse the repository at this point in the history
ZNK final cleanup
  • Loading branch information
zkamvar authored Oct 15, 2019
2 parents f8113f0 + 84b2ed7 commit 317fb8b
Show file tree
Hide file tree
Showing 44 changed files with 1,031 additions and 168 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
^examples
^codecov\.yml$
^\.github$
^docs
5 changes: 0 additions & 5 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@ export(find_end_date)
export(find_start_date)
export(fmt_ci)
export(fmt_ci_df)
export(fmt_ci_df_sep)
export(fmt_count)
export(fmt_pci)
export(fmt_pci_df)
export(fmt_pci_df_sep)
export(gen_data)
export(gen_polygon)
export(gen_population)
Expand All @@ -35,9 +33,6 @@ export(msf_dict_rename_helper)
export(msf_dict_survey)
export(plot_age_pyramid)
export(rename_redundant)
export(sample_size)
export(sample_size_households)
export(stratify_zscores)
export(tab_linelist)
export(tab_survey)
export(tab_univariate)
Expand Down
17 changes: 0 additions & 17 deletions R/helpers.R
Original file line number Diff line number Diff line change
@@ -1,20 +1,3 @@
# Helper function to splice a data.frame with multiple columns
# into a dplyr function
# example
# dplyr::summarise(mtcars,
# n = n(),
# x = sum(hp > 100),
# !!!splice_df(binom::binom.wilson(x, n), mean, lower, upper)
# )
splice_df <- function(x, ...) {
expr <- rlang::enquo(x)
cols <- lapply(rlang::ensyms(..., .named = TRUE), as.character)
lapply(cols, function(col_name) {
rlang::quo(`[[`(!!expr, !!col_name))
})
}


# This will convert numbers to factors.
#
# If the number of unique numbers is five or fewer, then they will simply
Expand Down
20 changes: 0 additions & 20 deletions R/inline_fun.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,26 +71,6 @@ merge_pci_df <- function(x, e = 3, l = e + 1, u = e + 2, digits = 2) {
x
}

#' @export
#' @rdname fmt_ci
fmt_ci_df_sep <- function(x, e = 3, l = e + 1, u = e + 2, digits = 2, percent = TRUE) {
x <- merge_ci_df(x, e, l, u, digits)
fun <- if (percent) match.fun(scales::percent) else match.fun(scales::number)
ee <- fun(x[[e]], scale = 1, accuracy = 1/(10^digits), big.mark = ",")
x[e] <- ee
x
}

#' @export
#' @rdname fmt_ci
fmt_pci_df_sep <- function(x, e = 3, l = e + 1, u = e + 2, digits = 2, percent = TRUE) {
x <- merge_pci_df(x, e, l, u, digits)
fun <- if (percent) match.fun(scales::percent) else match.fun(scales::number)
ee <- fun(x[[e]] * 100, scale = 1, accuracy = 1/(10^digits), big.mark = ",")
x[e] <- ee
x
}

#' Counts and proportions inline
#'
#' These functions will give proportions for different variables inline.
Expand Down
5 changes: 3 additions & 2 deletions R/nutrition.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
#' @param ... columns having zscore indicators
#'
#' @include helpers.R
#' @export
#' @keywords internal
#' @noRd
#' @examples
#' # A crude example, but it works
#' stratify_zscores(mtcars, by = "gear", am, vs)
Expand All @@ -19,7 +20,7 @@ stratify_zscores <- function(survey_data, by, ...) {
flagged = sum(.data$flagged, na.rm = TRUE),
rel = .data$flagged / .data$n,
ci = list(binom::binom.wilson(.data$flagged, .data$n)[, c("lower", "upper")]))
tidyr::unnest(res)
tidyr::unnest(res, cols = c("ci"))
}
dplyr::bind_rows(
comput_result(),
Expand Down
6 changes: 4 additions & 2 deletions R/sample-size.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
#' This method is based on the work of Kevin M. Sullivan and Andrew G. Dean
#' of OpenEpi.
#'
#' @export
#' @keywords internal
#' @noRd
sample_size <- function(population_size, expected_prevalence,
precision, design_effect, alpha = 0.05) {
num <- (design_effect * population_size * expected_prevalence *
Expand All @@ -33,7 +34,8 @@ sample_size <- function(population_size, expected_prevalence,
#' Sampling Methods and Sample Size Calculation for the SMART Methodology
#' <https://www.humanitarianresponse.info/sites/www.humanitarianresponse.info/files/documents/files/Sampling_Paper_June_2012.pdf>
#'
#' @export
#' @keywords internal
#' @noRd
sample_size_households <- function(sample_size, avg_hh,
prop_under_5,
frac_6_59, non_response_rate = 0) {
Expand Down
32 changes: 31 additions & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ The goal of {sitrep} is provide report templates for common epidemiological
surveys and outbreak reports. The package further contains helper function that
standardize certain analyses.

**Detailed information about the project and the templates can be found at <https://r4epis.netlify.com>.**
**Detailed information about the project and the templates can be found at <https://r4epis.netlify.com>.** An online manual for the functions in {sitrep} can be found at <https://r4epi.github.io/sitrep>.


## Installation
Expand All @@ -45,8 +45,38 @@ And the development version from [GitHub](https://github.com/) with:
remotes::install_github("R4EPI/sitrep")
```

## Available templates

Sitrep has [four outbreak templates](https://r4epis.netlify.com/outbreaks/) and
[three survey templates](https://r4epis.netlify.com/surveys/) available. These
templates will generate the following:

1. A word document with the situation report
2. A plain text markdown document (for conversion to other formats such as HTML or PDF)
3. A directory with all of the figures produced

You can generate an example template by using the `check_sitrep_templates()`
function:

```{r check_templates, warning = FALSE, message = FALSE}
library("sitrep")
output_dir <- file.path(tempdir(), "sitrep_example")
dir.create(output_dir)
# view the available templates, categorized by type
available_sitrep_templates(categorise = TRUE)
# generate the measles outbreak template in the output directory
check_sitrep_templates("measles_outbreak", path = output_dir)
# view the contents
list.files(output_dir, recursive = TRUE)
```


Please note that the 'sitrep' project is released with a
[Contributor Code of Conduct](.github/CODE_OF_CONDUCT.md).
By contributing to this project, you agree to abide by its terms.



76 changes: 75 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ epidemiological surveys and outbreak reports. The package further
contains helper function that standardize certain analyses.

**Detailed information about the project and the templates can be found
at <https://r4epis.netlify.com>.**
at <https://r4epis.netlify.com>.** An online manual for the functions in
{sitrep} can be found at <https://r4epi.github.io/sitrep>.

## Installation

Expand All @@ -39,3 +40,76 @@ And the development version from [GitHub](https://github.com/) with:
# install.packages("remotes")
remotes::install_github("R4EPI/sitrep")
```

## Available templates

Sitrep has [four outbreak
templates](https://r4epis.netlify.com/outbreaks/) and [three survey
templates](https://r4epis.netlify.com/surveys/) available. These
templates will generate the following:

1. A word document with the situation report
2. A plain text markdown document (for conversion to other formats such
as HTML or PDF)
3. A directory with all of the figures produced

You can generate an example template by using the
`check_sitrep_templates()` function:

``` r
library("sitrep")
output_dir <- file.path(tempdir(), "sitrep_example")
dir.create(output_dir)

# view the available templates, categorized by type
available_sitrep_templates(categorise = TRUE)
#> $outbreak
#> [1] "ajs_outbreak" "cholera_outbreak" "measles_outbreak"
#> [4] "meningitis_outbreak"
#>
#> $survey
#> [1] "mortality" "nutrition" "vaccination"

# generate the measles outbreak template in the output directory
check_sitrep_templates("measles_outbreak", path = output_dir)
#> [1] "/tmp/RtmpkK0upp/sitrep_example"

# view the contents
list.files(output_dir, recursive = TRUE)
#> [1] "measles_outbreak_files/figure-docx/age_pyramid-1.png"
#> [2] "measles_outbreak_files/figure-docx/bar_attack_rate_by_region-1.png"
#> [3] "measles_outbreak_files/figure-docx/biweekly_epicurve-1.png"
#> [4] "measles_outbreak_files/figure-docx/choropleth_maps-1.png"
#> [5] "measles_outbreak_files/figure-docx/epicurve_ar_cfr-1.png"
#> [6] "measles_outbreak_files/figure-docx/epicurve-1.png"
#> [7] "measles_outbreak_files/figure-docx/incidence_by_case_def-1.png"
#> [8] "measles_outbreak_files/figure-docx/incidence_by_gender-1.png"
#> [9] "measles_outbreak_files/figure-docx/incidence_by_sex_facility-1.png"
#> [10] "measles_outbreak_files/figure-docx/incidence_by_vax_status-1.png"
#> [11] "measles_outbreak_files/figure-docx/map_for_loop_epiweek-1.png"
#> [12] "measles_outbreak_files/figure-docx/map_for_loop_epiweek-10.png"
#> [13] "measles_outbreak_files/figure-docx/map_for_loop_epiweek-11.png"
#> [14] "measles_outbreak_files/figure-docx/map_for_loop_epiweek-12.png"
#> [15] "measles_outbreak_files/figure-docx/map_for_loop_epiweek-13.png"
#> [16] "measles_outbreak_files/figure-docx/map_for_loop_epiweek-14.png"
#> [17] "measles_outbreak_files/figure-docx/map_for_loop_epiweek-15.png"
#> [18] "measles_outbreak_files/figure-docx/map_for_loop_epiweek-16.png"
#> [19] "measles_outbreak_files/figure-docx/map_for_loop_epiweek-17.png"
#> [20] "measles_outbreak_files/figure-docx/map_for_loop_epiweek-18.png"
#> [21] "measles_outbreak_files/figure-docx/map_for_loop_epiweek-19.png"
#> [22] "measles_outbreak_files/figure-docx/map_for_loop_epiweek-2.png"
#> [23] "measles_outbreak_files/figure-docx/map_for_loop_epiweek-20.png"
#> [24] "measles_outbreak_files/figure-docx/map_for_loop_epiweek-3.png"
#> [25] "measles_outbreak_files/figure-docx/map_for_loop_epiweek-4.png"
#> [26] "measles_outbreak_files/figure-docx/map_for_loop_epiweek-5.png"
#> [27] "measles_outbreak_files/figure-docx/map_for_loop_epiweek-6.png"
#> [28] "measles_outbreak_files/figure-docx/map_for_loop_epiweek-7.png"
#> [29] "measles_outbreak_files/figure-docx/map_for_loop_epiweek-8.png"
#> [30] "measles_outbreak_files/figure-docx/map_for_loop_epiweek-9.png"
#> [31] "measles_outbreak.md"
#> [32] "measles_outbreak.Rmd"
```

Please note that the ‘sitrep’ project is released with a [Contributor
Code of Conduct](.github/CODE_OF_CONDUCT.md). By contributing to this
project, you agree to abide by its terms.
3 changes: 3 additions & 0 deletions docs/404.html

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

Loading

0 comments on commit 317fb8b

Please sign in to comment.