knitr::opts_chunk$set(
  warning = FALSE,
  message = FALSE,
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%",
  fig.retina = 2
)

covidutils

Centralised utility functions for covid related projects at Epicentre.

Installation

Install covidutils from github with:

remotes::install_github("epicentre-msf/covidutils")

Development

To include a function in the package, add it to a script in the R/ directory.

Best practices

If using RStudio, you can document, check and install the package with option in the 'Build' pane.

When developing new functions you can run devtools::load_all() at anytime load the current state of all function in the R/ directory.

Further R package development resources:

Function examples

library(tidyverse)
library(covidutils)

Import JHU CSSE data

df_covid <- get_owid_jhcsse()
glimpse(df_covid)

Compute 14 and 30 day case and death trends

df_trends <- get_country_summaries(df_covid)
glimpse(df_trends)
# country with fastest growing case numbers in last 14 days
(iso <- df_trends %>% 
  filter(trend_cases_coeff_14d == max(trend_cases_coeff_14d, na.rm = TRUE)) %>% 
  pull(iso_a3))
df_country <- df_covid %>% filter(iso_a3 == iso)
df_trends_country <- df_trends %>% filter(iso_a3 == iso)
country_plot(df_country, df_trends_country, add_title = TRUE)


epicentre-msf/covidutils documentation built on July 22, 2021, 1:03 p.m.