diff --git a/.Rbuildignore b/.Rbuildignore index 0a2fccb3..ff287c21 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -7,3 +7,4 @@ ^examples ^codecov\.yml$ ^\.github$ +^docs diff --git a/NAMESPACE b/NAMESPACE index b7ae6fbd..af52844e 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -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) @@ -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) diff --git a/R/helpers.R b/R/helpers.R index 5d1db186..4f91eabf 100644 --- a/R/helpers.R +++ b/R/helpers.R @@ -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 diff --git a/R/inline_fun.R b/R/inline_fun.R index 82d23ac2..bd9f1218 100644 --- a/R/inline_fun.R +++ b/R/inline_fun.R @@ -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. diff --git a/R/nutrition.R b/R/nutrition.R index 6df3409f..e9c50017 100644 --- a/R/nutrition.R +++ b/R/nutrition.R @@ -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) @@ -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(), diff --git a/R/sample-size.R b/R/sample-size.R index 2b8a2698..7fe2360f 100644 --- a/R/sample-size.R +++ b/R/sample-size.R @@ -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 * @@ -33,7 +34,8 @@ sample_size <- function(population_size, expected_prevalence, #' Sampling Methods and Sample Size Calculation for the SMART Methodology #' #' -#' @export +#' @keywords internal +#' @noRd sample_size_households <- function(sample_size, avg_hh, prop_under_5, frac_6_59, non_response_rate = 0) { diff --git a/README.Rmd b/README.Rmd index 071fd91a..b97b3dab 100644 --- a/README.Rmd +++ b/README.Rmd @@ -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 .** +**Detailed information about the project and the templates can be found at .** An online manual for the functions in {sitrep} can be found at . ## Installation @@ -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. + + diff --git a/README.md b/README.md index 70db729e..d0258608 100644 --- a/README.md +++ b/README.md @@ -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 .** +at .** An online manual for the functions in +{sitrep} can be found at . ## Installation @@ -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. diff --git a/docs/404.html b/docs/404.html index 1005ca9a..eb697937 100644 --- a/docs/404.html +++ b/docs/404.html @@ -81,6 +81,9 @@
  • Reference +
  • +
  • + Changelog
  • @@ -65,7 +68,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

    @@ -75,6 +78,69 @@

    +
    +

    +Available templates

    +

    Sitrep has four outbreak templates and three survey templates available. These templates will generate the following:

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

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

    +
    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. By contributing to this project, you agree to abide by its terms.

    +
    @@ -86,6 +152,13 @@

    License

  • GPL-3
  • +

    Developers

      diff --git a/docs/news/index.html b/docs/news/index.html new file mode 100644 index 00000000..e129ef89 --- /dev/null +++ b/docs/news/index.html @@ -0,0 +1,148 @@ + + + + + + + + +Changelog • sitrep + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      +
      + + + + +
      + +
      +
      + + +
      +

      +sitrep 0.1.0

      +
        +
      • Added a NEWS.md file to track changes to the package.
      • +
      • First official release of the {sitrep} package.
      • +
      +
      +
      + + + +
      + + +
      + + +
      +

      Site built with pkgdown 1.4.1.

      +
      + +
      +
      + + + + + + + + diff --git a/docs/reference/add_weights_cluster.html b/docs/reference/add_weights_cluster.html index 2ebc7e79..3496c47d 100644 --- a/docs/reference/add_weights_cluster.html +++ b/docs/reference/add_weights_cluster.html @@ -84,6 +84,9 @@
    • Reference +
    • +
    • + Changelog
    available_sitrep_templates(categorise = TRUE, full.names = TRUE)
    #> $outbreak -#> [1] "/tmp/RtmpwyNsp9/temp_libpath603f413d161e/sitrep/rmarkdown/templates/ajs_outbreak" -#> [2] "/tmp/RtmpwyNsp9/temp_libpath603f413d161e/sitrep/rmarkdown/templates/cholera_outbreak" -#> [3] "/tmp/RtmpwyNsp9/temp_libpath603f413d161e/sitrep/rmarkdown/templates/measles_outbreak" -#> [4] "/tmp/RtmpwyNsp9/temp_libpath603f413d161e/sitrep/rmarkdown/templates/meningitis_outbreak" +#> [1] "/tmp/RtmpVoMCI9/temp_libpath488280d8fe9/sitrep/rmarkdown/templates/ajs_outbreak" +#> [2] "/tmp/RtmpVoMCI9/temp_libpath488280d8fe9/sitrep/rmarkdown/templates/cholera_outbreak" +#> [3] "/tmp/RtmpVoMCI9/temp_libpath488280d8fe9/sitrep/rmarkdown/templates/measles_outbreak" +#> [4] "/tmp/RtmpVoMCI9/temp_libpath488280d8fe9/sitrep/rmarkdown/templates/meningitis_outbreak" #> #> $survey -#> [1] "/tmp/RtmpwyNsp9/temp_libpath603f413d161e/sitrep/rmarkdown/templates/mortality" -#> [2] "/tmp/RtmpwyNsp9/temp_libpath603f413d161e/sitrep/rmarkdown/templates/nutrition" -#> [3] "/tmp/RtmpwyNsp9/temp_libpath603f413d161e/sitrep/rmarkdown/templates/vaccination" +#> [1] "/tmp/RtmpVoMCI9/temp_libpath488280d8fe9/sitrep/rmarkdown/templates/mortality" +#> [2] "/tmp/RtmpVoMCI9/temp_libpath488280d8fe9/sitrep/rmarkdown/templates/nutrition" +#> [3] "/tmp/RtmpVoMCI9/temp_libpath488280d8fe9/sitrep/rmarkdown/templates/vaccination" #>