knitr::opts_chunk$set(echo = TRUE) library(jsonlite) library(ggplot2) library(readr) library(outbreakinfo)
Outbreak.info's Cases & Deaths Tracker allows you to compare trends in COVID-19 cases and deaths by location over time. We will walk you through how to run some essential queries. We can help you to answer questions like:
Import the packages we'll use to access the data.
Note that unlike the SARS-CoV-2 Variant Prevalence functions, none of the Cases & Deaths functions or anything in this vignette require GISAID authentication through the authenticateUser()
function.
# Package imports library(outbreakinfo)
The following is a data dictionary for your reference:
knitr::kable(epidemiologyDataDictionary())
Description:
Get ISO3 codes for World Bank regions, countries, states/provinces, metropolitan areas, and/or counties.
Usage:
getISO3(locations_to_search)
Arguments:
locations_to_search: a vector
or list
of location (World Bank region, country, state/province, metropolitan area, county) name(s)
Example:
iso3=getISO3(c("United States of America", "Brazil")) print(iso3)
Description:
Get exact spelling of locations at the same administrative level.
Usage:
searchLocations(locations_to_search, admin_level)
Arguments:
locations_to_search: a vector
or list
of location (World Bank region, country, state/province, metropolitan area, county) name(s) at the same administrative level
admin_level: an integer
representing an administrative level (World Bank regions = -1, countries = 0, states/provinces = 1, metropolitan areas = 1.5, counties = 2)
Example:
names=searchLocations(c("California", "Florida"), admin_level=1) print(names)
Description:
Retrieve a dataframe
of up-to-date COVID-19 data from outbreak.info according to user specifications.
Usage:
getEpiData(name=NULL, location_id=NULL, wb_region=NULL, country_name=NULL, state_name=NULL, admin_level=NULL, date=NULL, mostRecent=NULL, fields=NULL, sort, size=1000)
Arguments:
name: a vector
or list
of location (World Bank region, country, state/province, metropolitan area, county) name(s)
location_id: a vector
or list
of ISO3 codes representing locations (World Bank region, country, state/province, metropolitan area, county)
wb_region: a vector
or list
of World Bank region name(s)
country_name: a vector
or list
of country name(s)
state_name: a vector
or list
of state name(s)
admin_level: an integer
representing an administrative level (World Bank regions = -1, countries = 0, states/provinces = 1, metropolitan areas = 1.5, counties = 2)
date: a vector
or list
of date(s) as string(s) in YYYY-MM-DD format
mostRecent: a Boolean
(T/F) indicating if all data should be returned or only most recent
fields: a vector
of API fields to include in results
sort: a string
representing parameter to sort results by
size: an integer
representing size
Example:
df=getEpiData(name="United States of America", date="2020-07-01") df[!duplicated(df$name), c("name", "date", "confirmed", "dead")]
Description:
Retrieve a dataframe
of up-to-date COVID-19 data from outbreak.info for specified locaton(s) (World Bank region, country, state/province, metropolitan area, county).
Usage:
getLocationData(location_names)
Arguments:
location_names: a vector
or list
of location (World Bank region, country, state/province, metropolitan area, county) name(s)
Example:
df=getLocationData(location_names=c("Brazil", "San Diego")) df[!duplicated(df$name), c("name", "date", "confirmed")]
Description:
Retrieve a dataframe
of up-to-date COVID-19 data from outbreak.info for all countries.
Usage:
getAdmn0()
Arguments:
none
Example:
world_df=getAdmn0() length(unique(world_df$name))
Description:
Retrieve a dataframe
of up-to-date COVID-19 data from outbreak.info for all countries in one or more World Bank regions.
Usage:
getCountryByRegion(wb_regions)
Arguments:
wb_regions: a vector
or list
of World Bank region names
Example:
region_df=getCountryByRegion("South Asia") print(unique(region_df$name))
Description:
Retrieve a dataframe
of up-to-date COVID-19 data from outbreak.info for all states/provinces in one or more countries.
Usage:
getAdmn1ByCountry(countries)
Arguments:
countries: a vector
or list
of country names
Example:
state_df=getAdmn1ByCountry("India") print(unique(state_df$name))
Description:
Retrieve a dataframe
of up-to-date COVID-19 data from outbreak.info for all metropolitan areas in the United States of America.
Usage:
getMetroByCountry()
Arguments:
none
Example:
metro_df=getMetroByCountry()
Description:
Retrieve a dataframe
of up-to-date COVID-19 data from outbreak.info for all counties in the United States of America.
Usage:
getAdmn2ByCountry()
Arguments:
none
Example:
county_df=getAdmn2ByCountry()
Description:
Retrieve a dataframe
of up-to-date COVID-19 data from outbreak.info for all counties in given state(s).
Usage:
getAdmn2ByState(states)
Arguments:
states: a vector
or list
of state names
Example:
ca_df=getAdmn2ByState("California") length(unique(ca_df$name))
Description:
Retrieve a dataframe
of up-to-date COVID-19 data from outbreak.info for all locations at a specified administrative level.
Usage:
getByAdmnLevel(admin_level)
Arguments:
admin_level: an integer
representing an administrative level (World Bank regions = -1, countries = 0, states/provinces = 1, metropolitan areas = 1.5, counties = 2)
Example:
admin_df=getByAdmnLevel(-1) print(unique(admin_df$name))
Description:
Plot a metric of interest using up-to-date COVID-19 data using data from outbreak.info for location(s) of interest (World Bank region, country, state/province, metropolitan area, county)
Usage:
plotEpiData(locations, variable)
Arguments:
location: a vector
or list
of location name(s)
variable: metric to plot
Example:
p=plotEpiData(c("Brazil", "San Diego"), "confirmed_per_100k") show(p)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.