| Title: | Access the EPI State of Working America Data Library API |
|---|---|
| Description: | Provides functions to retrieve data from the Economic Policy Institute's State of Working America Data Library (SWADL) API. Enables users to explore available indicators, measures, and dimensions, and to fetch time series data at national, regional, and state levels. |
| Authors: | Ben Zipperer [aut, cre], Economic Policy Institute [cph, fnd] |
| Maintainer: | Ben Zipperer <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.2.0 |
| Built: | 2026-05-12 09:02:39 UTC |
| Source: | https://github.com/economic/swadlr |
Clears all cached metadata from the current R session. This includes cached topics, indicators, measures, dimensions, and sources. Use this function if you want to refresh metadata from the API.
clear_swadlr_cache()clear_swadlr_cache()
Invisible NULL.
clear_swadlr_cache()clear_swadlr_cache()
Retrieves time series data from the EPI State of Working America Data Library API.
get_swadl( indicator, measure, date_interval = c("year", "month"), geography = "national", dimension = "overall", date = NULL )get_swadl( indicator, measure, date_interval = c("year", "month"), geography = "national", dimension = "overall", date = NULL )
indicator |
Indicator ID (e.g., |
measure |
Measure ID (e.g., |
date_interval |
Either |
geography |
A geography specification. Accepts state names (e.g.,
|
dimension |
Dimension specification. Can be:
|
date |
Optional date filter. Can be:
|
A tibble with columns:
date: Observation date
value: The observed value
geography: Geography ID
One column per dimension in the request, containing dimension value IDs
swadl_indicator() for indicator details, swadl_id_names() to
list indicators, measures, and dimensions.
# Median hourly wage over time get_swadl( "hourly_wage_percentiles", "nominal_wage", dimension = list("wage_percentile" = "wage_p50") ) # All wage percentiles get_swadl( "hourly_wage_percentiles", "nominal_wage", dimension = "wage_percentile" ) # Employment rate for males by age group get_swadl( "labor_force_emp", "percent_emp", dimension = list("gender" = "gender_male", "age_group") ) # Filter to specific date range get_swadl( "hourly_wage_percentiles", "nominal_wage", dimension = "wage_percentile", date = c("2000-01-01", "2024-01-01") )# Median hourly wage over time get_swadl( "hourly_wage_percentiles", "nominal_wage", dimension = list("wage_percentile" = "wage_p50") ) # All wage percentiles get_swadl( "hourly_wage_percentiles", "nominal_wage", dimension = "wage_percentile" ) # Employment rate for males by age group get_swadl( "labor_force_emp", "percent_emp", dimension = list("gender" = "gender_male", "age_group") ) # Filter to specific date range get_swadl( "hourly_wage_percentiles", "nominal_wage", dimension = "wage_percentile", date = c("2000-01-01", "2024-01-01") )
Searches across all indicators to find which data is available matching specified criteria. Useful for answering questions like "Which indicators have state-level data by race?"
swadl_availability( indicator = NULL, measure = NULL, date_interval = NULL, geo_level = NULL, dimensions = NULL, dimensions_match = c("exact", "all", "any") )swadl_availability( indicator = NULL, measure = NULL, date_interval = NULL, geo_level = NULL, dimensions = NULL, dimensions_match = c("exact", "all", "any") )
indicator |
Character vector of indicator IDs to filter to. If |
measure |
Character vector of measure IDs to filter to. If |
date_interval |
Character vector of date intervals to filter to.
Valid values are |
geo_level |
Character vector of geographic levels to filter to.
Valid values are |
dimensions |
Character vector of dimension IDs to match. How these
are matched depends on |
dimensions_match |
How to match the
|
A tibble with columns:
Indicator identifier
Human-readable indicator name
"year", "quarter", or "month"
Measure identifier
"national", "state", or "division"
Dimension combination (e.g., "gender × race") or
"overall" for aggregate data
Start of available date range
End of available date range
swadl_indicator() for detailed information about a single
indicator, swadl_id_names() to list all indicators.
# Find all indicators with state-level gender data swadl_availability(geo_level = "state", dimensions = "gender", dimensions_match = "any") # Find indicators with a specific measure swadl_availability(measure = "percent_emp") # Find all availability for a specific indicator swadl_availability(indicator = "hourly_wage_percentiles") # Find indicators with exact "gender × race" combinations at national level swadl_availability(geo_level = "national", dimensions = c("gender", "race"), dimensions_match = "exact")# Find all indicators with state-level gender data swadl_availability(geo_level = "state", dimensions = "gender", dimensions_match = "any") # Find indicators with a specific measure swadl_availability(measure = "percent_emp") # Find all availability for a specific indicator swadl_availability(indicator = "hourly_wage_percentiles") # Find indicators with exact "gender × race" combinations at national level swadl_availability(geo_level = "national", dimensions = c("gender", "race"), dimensions_match = "exact")
Returns a tibble of ID-name mappings for SWADL metadata. Use this to understand what each ID represents.
swadl_id_names( what = c("topics", "indicators", "measures", "dimensions", "geographies"), topic = NULL, indicator = NULL )swadl_id_names( what = c("topics", "indicators", "measures", "dimensions", "geographies"), topic = NULL, indicator = NULL )
what |
The type of metadata to list. One of:
|
topic |
For |
indicator |
For |
A tibble. The columns depend on what:
id, name
id, name, topic_id, updated_date
id, name, format
dimension_id, dimension_name, value_id,
value_name
id, level, name, abbr
swadl_indicator() for detailed information about a single
indicator, get_swadl() for fetching time series data.
# List all topics swadl_id_names("topics") # List all indicators swadl_id_names("indicators") # List indicators for a specific topic swadl_id_names("indicators", topic = "wages") # List measures for a specific indicator swadl_id_names("measures", indicator = "hourly_wage_percentiles") # List dimensions swadl_id_names("dimensions") # List geographies swadl_id_names("geographies")# List all topics swadl_id_names("topics") # List all indicators swadl_id_names("indicators") # List indicators for a specific topic swadl_id_names("indicators", topic = "wages") # List measures for a specific indicator swadl_id_names("measures", indicator = "hourly_wage_percentiles") # List dimensions swadl_id_names("dimensions") # List geographies swadl_id_names("geographies")
Returns detailed information about a specific indicator including available measures, dimension combinations, date ranges, geographic availability, and sources.
swadl_indicator(indicator)swadl_indicator(indicator)
indicator |
The indicator ID (e.g., |
An S3 object of class swadl_indicator_info with the following
components:
Indicator identifier
Human-readable indicator name
Topic ID the indicator belongs to
Date the indicator was last updated
Tibble of available measures with columns: id,
name, format
Tibble of availability information with columns:
date_interval, measure_id, geo_level, dimensions, date_start,
date_end. The dimensions column contains dimension IDs joined with
x (using multiplication sign), or "overall" for aggregate data.
Tibble of sources with columns: measure_id,
source, url
swadl_id_names() to list available indicators, measures, and
dimensions.
# Get information about hourly wage percentiles info <- swadl_indicator("hourly_wage_percentiles") print(info) # Access specific components info$measures info$availability# Get information about hourly wage percentiles info <- swadl_indicator("hourly_wage_percentiles") print(info) # Access specific components info$measures info$availability