Skip to content

leg3/pipewelder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pipewelder

pipewelder is an R package for streamlined retrieval and cleaning of economic and public health time series data from:

  • Bureau of Labor Statistics (BLS)
  • Federal Reserve Economic Data (FRED)
  • Centers for Disease Control and Prevention (CDC)

It provides two layers of functionality:

  • The get_*() functions retrieve data for a single series ID from each respective source.
  • The construct_*() functions operate on a named list of series metadata tibbles (such as those returned by get_full_gsheet()), iterating over each entry to retrieve and clean data for multiple series at once.

The output is a named list of tibbles, where each tibble represents a cleaned time series. Instead of inserting the series ID as a column, each tibble is tagged using attr(x, "series_id") to preserve the series identifier without modifying the data structure.

Functions included:

  • get_bls() retrieves BLS labor force data
  • get_fred() retrieves FRED macroeconomic indicators
  • get_cdc() retrieves CDC mortality and health surveillance data
  • construct_bls() builds cleaned BLS data from a list of series metadata
  • construct_fred() builds cleaned FRED data from a list of series metadata
  • construct_cdc() builds cleaned CDC data from a list of metadata tabs, auto-detecting schema structure

Every construct_*() function has a caching mechanism which caches the retrieved data to ~\pipewelder-cache. The cache can be flushed with the flush = TRUE parameter but should retrieve fresh data once each calendar day. All construct_*() functions also include default date parameters, which differ by source. Be sure to review the documentation to understand the behavior for each.

Installation

You can install pipewelder from GitHub with:

install.packages("pak") # Install 'pak' if not present
pak::pak("leg3/pipewelder")

Examples

Retrieve a Google sheet to use as a input for the construct_*() functions:

url <- "https://docs.google.com/spreadsheets/d/your-sheet-id/edit#gid=0"
sheet <- get_full_gsheet(url)

Retrieve series data from BLS:

# Set your API key
Sys.setenv(BLS_KEY = "your_api_key")

# Retrieve a single series of BLS data from 2000 to 2023
bls_df <- get_bls("LNS14000000", 2000, 2023)

# Construct a list of tibbles using a Google Sheet as input
BLS <- construct_bls(sheet)

Retrieve series data from FRED

# Set your API key
Sys.setenv(FRED_KEY = "your_api_key")

# Retrieve a single series of FRED data from 1990 to the present
fred_df <- get_fred("VIXCLS", "1990-01-01")

# Construct a list of tibbles using a Google Sheet as input
FRED <- construct_fred(sheet)

Retrieve series data from CDC

# Retrieve a single series of CDC data with date defaults
cdc_df <- get_cdc("9j2v-jamp")

# Construct a list of tibbles using a Google Sheet as input
CDC <- construct_cdc(sheet)

License

This project is licensed under the PolyForm Noncommercial License 1.0.0. Commercial use is not permitted without separate permission from Leg3 Inc. See LICENSE for details.


Generated from README.Rmd using devtools::build_readme().

Releases

No releases published

Packages

 
 
 

Contributors

Languages