Learn R Programming

rHealthDataGov (version 1.0.1)

fetch_healthdata: Fetch HealthData.gov data sets

Description

Query and retrieve data from the HealthData.gov data API.

Usage

fetch_healthdata(resource = "hosp", filter = NULL)

Arguments

resource
A string that identifies the name of the desired data resource. See the resources object for names and descriptions of the available data resources. Any name from the resources$resource column can be a value here.
filter
A list of named filters to apply to the API call. The named list elements must be a field in the given resource. To return all records from a particular data resource, set filter to NULL.

Value

A data frame containing the results of the API query.

Details

The resources data frame and filters list will be lazy-loaded automatically when you load the package. You can also load them explicitly using the data(resources) and data(filters) commands. The filter(s) will be applied on the server-side.

References

http://www.healthdata.gov/data-api

Examples

Run this code
## Not run: 
# df <- fetch_healthdata(resource="hosp", filter=list(addr_city="SAN FRANCISCO"))
# head(df)
# 
# #       addr_city provider_id    tel_nbr seqn              addr_line_1
# # 1 SAN FRANCISCO       50076 4158332646   38          2425 GEARY BLVD
# # 2 SAN FRANCISCO       50228 4152068000  641      1001 POTRERO AVENUE
# # 3 SAN FRANCISCO       50668 4157592300  660    375 LAGUNA HONDA BLVD
# # 4 SAN FRANCISCO       50008 4156006000 1207         45 CASTRO STREET
# # 5 SAN FRANCISCO       50152 4153536000 2353              900 HYDE ST
# # 6 SAN FRANCISCO       50055 4156416562 2911 3555 CESAR CHAVEZ STREET
# #                                ownership_type hsp_accreditation addr_postalcode
# # 1 Government - Hospital District or Authority                             94115
# # 2                          Government - Local                             94110
# # 3                          Government - Local                             94116
# # 4                Voluntary non-profit - Other                             94114
# # 5              Voluntary non-profit - Private                             94109
# # 6               Voluntary non-profit - Church                             94110
# #   emergency_serv_type addr_state  _id hospital_type
# # 1                 Yes         CA   38    Short-term
# # 2                 Yes         CA  641    Short-term
# # 3                 Yes         CA  660    Short-term
# # 4                 Yes         CA 1207    Short-term
# # 5                 Yes         CA 2353    Short-term
# # 6                 Yes         CA 2911    Short-term
# #                                             hsp_name county_cd
# # 1         KAISER FOUNDATION HOSPITAL - SAN FRANCISCO       480
# # 2                     SAN FRANCISCO GENERAL HOSPITAL       480
# # 3      LAGUNA HONDA HOSPITAL & REHABILITATION CENTER       480
# # 4  CALIFORNIA PACIFIC MEDICAL CTR-DAVIES CAMPUS HOSP       480
# # 5                    SAINT FRANCIS MEMORIAL HOSPITAL       480
# # 6  CALIFORNIA PACIFIC MEDICAL CTR - ST. LUKES CAMPUS       480
# 
# ## End(Not run)

Run the code above in your browser using DataLab