knitr::opts_chunk$set(
  message = FALSE,
  warning = FALSE,
  error = FALSE,
  collapse = TRUE,
  comment = "#>"
)

In this vignette, we show how to perform the OxCOVID19 Database access examples shown here using R and the oxcovid19 package.

Epidemiology table

List of available sources

The task here is to list out all the unique epidemiology table sources sorted alphabetically.

library(oxcovid19)
library(magrittr)
library(dplyr)

connect_oxcovid19() %>%                      ## Connect to PostgreSQL server
  get_table(tbl_name = "epidemiology") %>%   ## Retrieve epidemiology table
  arrange(source) %>%                        ## Sort the table by source
  select(source) %>%                         ## Select the source column
  distinct() %>%                             ## Get only unique sources
  pull(source)                                 

Data for single source

In this example, the task is to retrieve the epidemiology table and then get only the data from source GBR_PHTW and then sort resulting dataset by decreasing date.

connect_oxcovid19() %>%                      ## Connect to PostgreSQL server
  get_table(tbl_name = "epidemiology") %>%   ## Retrieve epidemiology table
  filter(source == "GBR_PHTW") %>%           ## Select specific source
  arrange(desc(date))                        ## Sort by date

For both tasks, the results in the example were replicated in R using the oxcovid19 functions.

Mobility

The task here was to retrieve the mobility table from the PostgreSQL server and then extract only those with GOOGLE_MOBILITY as the source and GBR as the country code. Finally, the resulting table is sorted by date.

connect_oxcovid19() %>%                      ## Connect to PostgreSQL server
  get_table(tbl_name = "mobility") %>%       ## Retrieve mobility table
  filter(source == "GOOGLE_MOBILITY",        ## Get only data from `Google`
         countrycode == "GBR") %>%           ## Get only data from `GBR`
  arrange(desc(date))                        ## Sort by date

The results match the results shown in the examples.



como-ph/oxcovid19 documentation built on April 29, 2021, 10:29 p.m.