knitr::opts_chunk$set( warning = FALSE, message = FALSE, collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%", fig.retina = 2 )
Centralised utility functions for covid related projects at Epicentre.
Install covidutils from github with:
remotes::install_github("epicentre-msf/covidutils")
To include a function in the package, add it to a script in the R/
directory.
.R
script inside the R/
directory with an information name, get_ecdc.R
for exampleutils.R
dplyr::filter()
DESCRIPTION
file. This can be done via usethis::use_package("name_of_package")
devtools::document()
to build the appropriate documentation filesdevtools::check()
to check the package for any errors or warningsdevtools::install()
to install or re-install the package on your systemREADME.Rmd
below then knit the document to produce the .md
format required for githubIf 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:
library(tidyverse) library(covidutils)
df_covid <- get_owid_jhcsse() glimpse(df_covid)
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.