knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
# whether to import new data or use cached data import_new_data = TRUE # path to cache folder to read from and write to for this project path_to_cache_folder = ".cache/example_analysis" # set random seed set.seed(12345)
SeroTracker research code also uses the tidyverse
, an ecosystem of data analysis tools including libraries like ggplot2
, dplyr
, and tibble
. Prioritize finding and implementing tidyverse
approaches to your data input, transformation, and plotting needs, where possible.
library(tidyverse)
The custom serosurvr
library is contained in a public GitHub repo: serotracker/serosurvr
.
library("devtools") devtools::install_github("serotracker/serosurvr") library("serosurvr") # load newest serosurvr
Sample functions that demonstrate how to get data.
#create a data request fs_males_req <- serosurvr::datareq_params(reqname = "france_spain_males", research_fields = TRUE, estimates_subgroup = 'prioritize_estimates', prioritize_estimates_mode = "analysis_dynamic", publication_end_date = "2020-12-31", filters = list()) # pipe data request to get_data function to request data fs_males_tbl <- fs_males_req %>% serosurvr::get_data(import_new_data = import_new_data, path_to_cache_folder = path_to_cache_folder) fs_males_tbl
Get a list of the filter options that can be used in data requests.
serosurvr::filter_options()
Sample functions that demonstrate how to clean data.
# enforce_st_dtypes enforces correct dtypes on all columns fs_males_tbl_cleaned <- fs_males_req %>% serosurvr::get_data(import_new_data = import_new_data, path_to_cache_folder = path_to_cache_folder) %>% serosurvr::enforce_st_dtypes() fs_males_tbl_cleaned
# enforce_st_dtypes enforces correct dtypes on all columns ab_on_tbl_cleaned <- serosurvr::datareq_params(reqname = "ab_on_studies", research_fields = TRUE, estimates_subgroup = 'prioritize_estimates', prioritize_estimates_mode = "dashboard", filters = list(country = list('Canada'), state = list('Alberta', 'Ontario'))) %>% serosurvr::get_data(import_new_data = import_new_data, path_to_cache_folder = path_to_cache_folder, server = 'dev') %>% serosurvr::enforce_st_dtypes() ab_on_tbl_cleaned
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.