Code Monkey home page Code Monkey logo

apyramid's Introduction

Sitrep

Lifecycle: maturing CRAN status Codecov test coverage R build status

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.

While templates are primarily for MSF analyses - they have been setup to be as generic as possible for use by the general applied epidemiology community.

Detailed information about the project and the templates can be found at https://r4epis.netlify.com.
A reference website for the functions in {sitrep} can be found at https://r4epi.github.io/sitrep.

{sitrep} includes a number of other R packages which facilitate specific analysis:
{epitabulate}: Tables for epidemiological analysis
{epidict}: Epidemiology data dictionaries and random data generators
{epikit}: Miscellaneous helper tools for epidemiologists
{apyramid}: Age pyramid construction and plotting

Installation

The {sitrep} package, is currently stored in a GitHub repository. Therefore, the procedure to install these packages have one extra step required.

To install sitrep from GitHub you must first install the remotes package.

# install.packages("remotes")
remotes::install_github("r4epi/sitrep")

If you are getting errors, check the frequently asked questions.

Available templates

Sitrep has four outbreak templates and four survey templates 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 access the list of templates in R Studio by clicking (see example below): file > New file > R Markdown… > From Template

Example of how to open and save the cholera template

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_long" 
#> [4] "vaccination_short"

# generate the measles outbreak template in the output directory
check_sitrep_templates("measles_outbreak", path = output_dir)
#> [1] "C:\\Users\\alexf\\AppData\\Local\\Temp\\Rtmpcv1H8d/sitrep_example"

# view the contents
list.files(output_dir, recursive = TRUE)
#> [1] "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.

apyramid's People

Contributors

hadley avatar zkamvar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

apyramid's Issues

dplyr group_by warning

plot age_pyramid function throws this warning when using the call below from the vaccination template.

just flagging because dont want to go fishing around and mess things up!


plot_age_pyramid(survey_design,
                 age_group = "age_group",
                 split_by = "sex", 
                 proportion = TRUE) +
  labs(y = "Proportion", x = "Age group (years)") +                 # change axis labels
  theme(legend.position = "bottom",     # move legend to bottom
        legend.title = element_blank(), # remove title
        text = element_text(size = 18)  # change text size
       )

Warnmeldung:
The add argument of group_by() is deprecated as of dplyr 1.0.0.
Please use the .add argument instead.
This warning is displayed once every 8 hours.
Call lifecycle::last_warnings() to see where this warning was generated.

Release apyramid 0.1.0

Prepare for release:

  • Check that description is informative
  • Check licensing of included files
  • usethis::use_cran_comments()
  • devtools::check()
  • devtools::check_win_devel()
  • rhub::check_for_cran()
  • Polish pkgdown reference index
  • Draft blog post

Submit to CRAN:

  • usethis::use_version('minor')
  • Update cran-comments.md
  • devtools::submit_cran()
  • Approve email

Wait for CRAN...

  • Accepted 🎉
  • usethis::use_github_release()
  • usethis::use_dev_version()
  • Update install instructions in README
  • Finish blog post
  • Tweet
  • Add link to blog post in pkgdown news menu

Fix test for ggplot2 3.3.0

I got an email from Kurt a couple of days ago:

Dear maintainer,

Please see the problems shown on
https://cran.r-project.org/web/checks/check_results_apyramid.html.

Please correct before 2020-03-20 to safely retain your package on CRAN.

Best,
-k


Version: 0.1.0
Check: tests
Result: ERROR
Running 'testthat.R' [14s/17s]
Running the tests in 'tests/testthat.R' failed.
Complete output:
> library(testthat)
> library(apyramid)
>
> test_check("apyramid")
-- 1. Failure: missing split data are removed before plotting (@test-age-pyramid
age_pyramid(dat, age_group = "AGE", na.rm = FALSE) produced warnings.

 == testthat results ===========================================================
 [ OK: 72 | SKIPPED: 11 | WARNINGS: 11 | FAILED: 1 ]
 1. Failure: missing split data are removed before plotting (@test-age-pyramid.R#171) 

update for dplyr version 1.0.0

Dear Zhian N. Kamvar,

This is an automated email to let you know that:

  • A new version of dplyr is ready to go to CRAN. dplyr is
    currently at version 0.8.99.9002 and will become 1.0.0 upon release.

  • apyramid uses dplyr and has problems with the new version.

  • We plan to submit dplyr to CRAN on May 1.

This is a major release. See
https://www.tidyverse.org/blog/2020/03/dplyr-1-0-0-is-coming-soon/ for
a detailed article about what's changed.

I need your help to keep apyramid and dplyr working together smoothly.
In the next weeks, can you please:

  1. Read about the changes to dplyr at
    https://github.com/tidyverse/dplyr/blob/master/NEWS.md.
    This page includes a list of breaking changes, the reasoning behind
    them, and to how to update your code.

  2. Carefully inspect the failing checks listed at the bottom of this email.

  3. For each failing check, either update your package, or tell me
    that I have a bug. If you have made changes to your package, please
    submit an update to CRAN before May 1.

If you have discovered a bug in dplyr, please file an issue (ideally
with a small reprex that illustrates the problem) at
https://github.com/tidyverse/dplyr/issues. If you're not sure whether
or not you've found a bug, please file an issue at
https://github.com/tidyverse/dplyr/issues for discussion. Breaking
changes that are not listed qualify as bugs.

Please respond to this message if you have any questions.

Thanks,

Romain Francois

== CHECK RESULTS ========================================

  • checking examples ... ERROR
...

### ** Examples


library(ggplot2)
old <- theme_set(theme_classic(base_size = 18))

# with pre-computed data
----------------------------------------------------
# 2018/2008 US census data by age and gender
data(us_2018)
data(us_2008)
age_pyramid(us_2018, age_group = age, split_by = gender, count = count)
Error: Column 'n' is already present in output
 * Use `name = "new_name"` to pick a new name
Backtrace:
    █
 1. └─apyramid::age_pyramid(...)
 2.   └─dplyr::tally(maxdata, wt = !!quote(n))
 3.     └─dplyr:::check_name(x, name)
 4.       └─dplyr:::glubort(...)
Execution halted
  • checking tests ...
 ERROR
Running the tests in ‘tests/testthat.R’ failed.
Last 13 lines of output:
  ── 1. Error: (unknown) (@test-age-pyramid.R#77)
───────────────────────────────
  Column 'n' is already present in output
   * Use `name = "new_name"` to pick a new name
  Backtrace:
   1. apyramid::age_pyramid(dat, age_group = "AGE")
   2. dplyr::tally(maxdata, wt = !!quote(n))
   3. dplyr:::check_name(x, name)
   4. dplyr:::glubort(...)

  ══ testthat results
═══════════════════════════════════════════════════════════
  [ OK: 51 | SKIPPED: 0 | WARNINGS: 0 | FAILED: 1 ]
  1. Error: (unknown) (@test-age-pyramid.R#77)

  Error: testthat unit tests failed
  Execution halted

CRAN failures: Apology required

CRAN has been failing with the new forcats (which was thankfully addressed in #9).

Now I need to make sure this gets up to CRAN with an apology to the team:

Your test obfuscation package manages to produce a completely useless
error message.  Doing some manual editing I got

── Warning (test-age-pyramid.R:172): missing split data are removed
before plotting ──
There was 1 warning in `mutate()`.
ℹ In argument: `AGE = (function (f, na_level = "(Missing)") ...`.
Caused by warning:
! `fct_explicit_na()` was deprecated in forcats 1.0.0.
ℹ Please use `fct_na_value_to_level()` instead.
ℹ The deprecated feature was likely used in the apyramid package.
   Please report the issue at <https://github.com/R4EPI/apyramid/issues>.

Well, that is not how CRAN works.

Apologies expected, and any future submissions *MUST* behave in a way
that respects CRAN time, for as the policy says

"The time of the volunteers is CRAN’s most precious resource"

I'm honestly baffled about what BDR is complaining about here, but I'm sure he is not being charitable.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.