Slides

Exercise 1

Sign up for an API token and write code to download the longitudinal and cross-sectional Covid19 wastewater datasets using your token.

Download the longitudinal data, which we are storing as “covid”.

covid <- read.socrata(
  "https://data.cdc.gov/resource/g653-rqe2.json",
  app_token = "YOURAPPTOKENHERE",
  email     = "user@example.com",
  password  = "fakepassword"
)

Download the cross-sectional data, which we are storing as “counties”.

counties <- read.socrata(
  "https://data.cdc.gov/resource/2ew6-ywp6.json",
  app_token = "YOURAPPTOKENHERE",
  email     = "user@example.com",
  password  = "fakepassword"
)

Exercise 2

For the cross-sectional data, use a query on the field wwtp_jurisdiction to only select rows labeled “Georgia”. How many rows are returned?

counties <- read.socrata(
  "https://data.cdc.gov/resource/2ew6-ywp6.json?wwtp_jurisdiction='Georgia'",
  app_token = "YOURAPPTOKENHERE",
  email     = "user@example.com",
  password  = "fakepassword"
)

Another equivalent way of writing this query is given below:

counties <- read.socrata(
  "https://data.cdc.gov/resource/2ew6-ywp6.json?$where=wwtp_jurisdiction in('Georgia')",
  app_token = "YOURAPPTOKENHERE",
  email     = "user@example.com",
  password  = "fakepassword"
)

Additional readings