C3.ai COVID-19 Data Lake Quickstart in R

Viewed 153

I am working on a research assignment on COVID and using the datalake API to fetch different kind of datasets available to us.

I am wondering if it's possible to fetch all outbreak countries.

ids = list("Australia"), this works with individual country, it doesnt seem to accept wildcard or all.

Can anyone give me any insights on this please.

# Total number of confirmed cases in Australia and proportion of getting infected.
today <- Sys.Date()

casecounts <- evalmetrics(
  "outbreaklocation",
  list(
    spec = list(
      **ids = list("Australia"),**
      expressions = list("JHU_ConfirmedCasesInterpolated","JHU_ConfirmedDeathsInterpolated"),
      start = "2019-12-20",
      end = today-1,
      interval = "DAY"
    )
  )
)

casecounts
1 Answers

The easiest way to access a list of countries is in the Excel file linked at https://c3.ai/covid-19-api-documentation/#tag/OutbreakLocation. It has a list of countries in the first sheet, and shows which of those have data from JHU.

You could also fetch an approximate list of country-level locations with:

locations <- fetch(
    "outbreaklocation",
    list(
      spec = list(
        filter = "not(contains(id, '_'))"
      )
    )
)

That should contain all of the countries, but could have some non-countries like World Bank regions.

Then, you'd use this code to get the time series data for all of those locations:

location_ids <- 
  locations %>% 
  dplyr::select(-location) %>% 
  unnest_wider(fips, names_sep = ".") %>% 
  sample_n(15) %>% # include this to test on a smaller set
  pull(id)

today <- Sys.Date()

casecounts <- evalmetrics(
  "outbreaklocation",
  list(
    spec = list(
      ids = location_ids,
      expressions = list("JHU_ConfirmedCasesInterpolated","JHU_ConfirmedDeathsInterpolated"),
      start = "2019-12-20",
      end = today-1,
      interval = "DAY"
    )
  ),
  get_all = TRUE
)

casecounts
Related