getData: Request data from the CDC Wonder API

View source: R/getData.R

getDataR Documentation

Request data from the CDC Wonder API

Description

calls the CDC Wonder API and returns a tidy data frame (tibble)

Usage

getData(
  db = "D66",
  querylist = NULL,
  add = TRUE,
  save = FALSE,
  fn = "query.xml",
  agree = TRUE
)

Arguments

db

Indicate the database, either by label, name, or code. To see the complete list of what's available, use 'show_databases()'

querylist

The query list supplied must be a list of lists of names and values. By default it is combined with the default query list for that database. To supply a full list and bypass the default query list, set add to TRUE. See here for instructions on how to create this list.

add

If TRUE (default) querylist is combined with the default query list. Set to FALSE to use querylist as a standalone list of query parameters.

save

If TRUE the query list will be saved, defaults to FALSE

fn

filename for saved query list, defaults to query.xml.

agree

Must be set to TRUE to agree to the CDC terms (default is TRUE). To see the terms for the particular dataset click on that dataset here: https://wonder.cdc.gov. sample

Details

Queries for mortality and births statistics from the National Vital Statistics System cannot limit or group results by any location field, such as Region, Division, State or County, or Urbanization (urbanization categories map to specific geographic counties).

For example, in the D76 online database for Detailed Mortality 1999-2013, the location fields are D76.V9, D76.V10 and D76.V27, and the urbanization fields are D76.V11 and D76.V19. These 'sub-national" data fields cannot be grouped by or limited via the API, although these fields are available in the web application.

See https://wonder.cdc.gov/wonder/help/WONDER-API.html for more information.

References

Inspired by this script from the wondr package, but provides more user-friendly options and better table display: /urlhttps://github.com/hrbrmstr/wondr/blob/master/README.md

Examples

mylist <- list(
  list("And By", "Race"),
  list("And By", "Tobacco Use")
)

mydata <- getData("D66", mylist)
mydata


socdataR/natality documentation built on March 20, 2024, 8:40 p.m.