Giter Club home page Giter Club logo

epikit'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.

epikit's People

Contributors

aspina7 avatar hadley avatar krlmlr avatar zkamvar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

hadley

epikit's Issues

CFR need to be fixed?

The case fatality rate needs to have the denominator be based on non-missing data rather than total number of rows. At the moment, it is based on the total number of rows, which could throw off the CFR:

epikit/R/cfr.R

Line 106 in d106e54

!!quote(population) := dplyr::n(),

This should be fixed to be something more like dplyr::n() - sum(is.na(!!qdeath))

release to CRAN needed

CRAN has been breathing down my neck about epikit and apyramid. Both of these are at risk of being archived (and a big headache for me) if I don't upload them by Tuesday.

Here are some failing checks that were fixed by Hadley a few weeks ago:

Version: 0.1.2
Check: tests
Result: ERROR
     Running ‘testthat.R’ [4s/5s]
    Running the tests in ‘tests/testthat.R’ failed.
    Complete output:
     > library(testthat)
     > library(epikit)
     >
     > test_check("epikit")
     [ FAIL 1 | WARN 1 | SKIP 1 | PASS 111 ]
    
     ══ Skipped tests ═══════════════════════════════════════════════════════════════
     • On CRAN (1)
    
     ══ Failed tests ════════════════════════════════════════════════════════════════
     ── Error ('test-age-categories.R:179'): years alone give years ─────────────────
     Error in `forcats::fct_drop(res, droppings)`: `only` must be a character vector or `NULL`, not a logical vector.
     Backtrace:
     ▆
     1. └─epikit::group_age_categories(df, years = years, one_column = FALSE) at test-age-categories.R:179:2
     2. └─forcats::fct_drop(only = droppings)
     3. └─forcats:::check_character(only, allow_null = TRUE)
     4. └─forcats:::stop_input_type(...)
     5. └─rlang::abort(message, ..., call = call, arg = arg)
    
     [ FAIL 1 | WARN 1 | SKIP 1 | PASS 111 ]
     Error: Test failures
     Execution halted
Flavors: [r-devel-linux-x86_64-debian-clang](https://www.r-project.org/nosvn/R.check/r-devel-linux-x86_64-debian-clang/epikit-00check.html), [r-patched-linux-x86_64](https://www.r-project.org/nosvn/R.check/r-patched-linux-x86_64/epikit-00check.html), [r-release-linux-x86_64](https://www.r-project.org/nosvn/R.check/r-release-linux-x86_64/epikit-00check.html)

The last set of checks that worked were from #31, so that's the version I am going to submit.

I am not going to submit the version as it is now with #32 because of two things:

  1. it does not pass checks
  2. it adds another non-CRAN dependency which will make submitting to CRAN even more hellish.

Add more tests

At the moment, the inline funs are lacking some test coverage. We should fix this.

`find_start_date()` not working as intended

The idea of the find_start_date() and find_end_date() functions is excellent, and I find that the latter works exactly as intended. A really nice and useful function. However, I think there is an issue with find_start_date().

When trying to find the appropriate start date, you want the later of recall_begin, date_join, and date_born, not the earlier. As it is currently implemented, it always returns the beginning of the recall period, even if someone joins or is born during the recall period. It works as intended for end dates, though, as you want the earlier date, not the later.

Release epikit 0.1.0

Prepare for release:

  • Check that description is informative
  • Check licensing of included files
  • usethis::use_cran_comments()
  • Remove Remotes: section for CRAN
  • 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()
  • usethis::use_news_md()
  • Update install instructions in README
  • Finish blog post
  • Tweet
  • Add link to blog post in pkgdown news menu

Compatibility with dplyr 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.

  • epikit 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 epikit 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
Running examples in ‘epikit-Ex.R’ failed
The error most likely occurred in:

### Name: fmt_count
### Title: Counts and proportions inline
### Aliases: fmt_count

### ** Examples


fmt_count(mtcars, cyl > 3, hp < 100)
Error: `new` must be a tibble
Backtrace:
    █
 1. └─epikit::fmt_count(mtcars, cyl > 3, hp < 100)
 2.   └─dplyr::count(f)
 3.     └─dplyr::dplyr_reconstruct(out, x)
Execution halted
  • checking tests ...
 ERROR
Running the tests in ‘tests/testthat.R’ failed.
Last 13 lines of output:
   5. dplyr::count(f)
   6. dplyr::dplyr_reconstruct(out, x)

  ── 2. Failure: case_fatality_rate_df is equivalent to the non-df
version (@test-
  `iris_res` not equal to `iris_expect`.
  Attributes: < Component "class": Lengths (3, 1) differ (string
compare on first 1) >
  Attributes: < Component "class": 1 string mismatch >

  ══ testthat results
═══════════════════════════════════════════════════════════
  [ OK: 104 | SKIPPED: 1 | WARNINGS: 0 | FAILED: 2 ]
  1. Error: fmt_count() works as expected (@test-inline_fun.R#65)
  2. Failure: case_fatality_rate_df is equivalent to the non-df
version (@test-proportion.R#74)

  Error: testthat unit tests failed
  Execution halted

Triage inline functions

There are some inline functions that are super redundant and may be confusing to users. These should be removed

"notes" from devtools::check()

@zkamvar - do we need to deal with notes from devtools::check()

{stats} is part of base at this point no?

── R CMD check results ──────────────────────────────────────────────────────── epikit 0.1.4 ────
Duration: 41.9s

❯ checking package dependencies ... NOTE
Package suggested but not available for checking: 'covr'

❯ checking R code for possible problems ... NOTE
add_weights_cluster: no visible global function definition for
'setNames'
Undefined global functions or variables:
setNames
Consider adding
importFrom("stats", "setNames")
to your NAMESPACE file.

0 errors ✔ | 0 warnings ✔ | 2 notes ✖

separator argument in unite_ci()

Hello,

Would it be possible to add a "separator" argument to the unite_ci() function to be able to modify the default "--" between values?

It is sometimes changed to "to" or just "-"
Appreciate it.

Change the name to epikit

n.b. epimisc is technically already taken.

Since this is a more general-use package inline stuff and other things, it's not necessarily epi-related.

clean up intro rmdhunks

had commented some stuff out because erroring with the moving of props functions #32
need to fix up the examples appropratiely.

add basic README

  • use man/rmdhunks/ knitr child chunks to build it a la apyramid
  • demonstrate inline stylings
  • demonstrate renamers
  • demonstrate rate tables
  • demonstrate age groupings

age_categories lowest age label incorrectly formatted


Problem:

When specific breaks are defined for the age_categories() function, there is special formatting for the upper number, but the lower number is incorrectly formatted as a range with itself.

For example, if the lowest number is 0, the label for the first category will be 0-0.

Proposed solution:

I think it should be reformatted to be less than the second number in the list of breaks, i.e. if the breaks are 0, 1, 5, 10 the first label should be <1.

Reprex below:

# Load epikit:
library(epikit)

# Vector of ages in years:
age <- c(3, 1, 8, 1, 0.5, 6, 7, 2, 11, 15)

# Create age categories:
agegroups <- epikit::age_categories(x = age, breakers = c(0, 1, 5, 10))

# Combine into a data.frame and sort ascending by age:
df <- data.frame(age, agegroups) %>% arrange(age)

This gives the following results:

> df
    age agegroups
1   0.5       0-0
2   1.0       1-4
3   1.0       1-4
4   2.0       1-4
5   3.0       1-4
6   6.0       5-9
7   7.0       5-9
8   8.0       5-9
9  11.0       10+
10 15.0       10+

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.