Title: | An API Wrapper for the United States Bureau of Labor Statistics |
---|---|
Description: | Scrapes various data from <https://www.bls.gov/>. The Bureau of Labor Statistics is the statistical branch of the United States Department of Labor. The package has additional functions to help parse, analyze and visualize the data. |
Authors: | Kris Eberwein [aut, cre] |
Maintainer: | Kris Eberwein <[email protected]> |
License: | MIT + file LICENSE |
Version: | 4.0.1 |
Built: | 2024-11-13 04:28:31 UTC |
Source: | https://github.com/keberwein/blscraper |
Return data frame from one or more requests via the US Bureau of Labor Statistics API. Provided arguments are in the form of BLS series ids.
bls_api( seriesid, startyear = NULL, endyear = NULL, registrationKey = NULL, catalog = FALSE, calculations = FALSE, annualaverage = FALSE, ... )
bls_api( seriesid, startyear = NULL, endyear = NULL, registrationKey = NULL, catalog = FALSE, calculations = FALSE, annualaverage = FALSE, ... )
seriesid |
The BLS id of the series your trying to load. A common format would be 'LAUCN040010000000005'. WARNING: All seriesIDs must contain the same time resolution. For example, monthly data sets can not be combined with annual or semi-annual data. If you need help finding seriesIDs, check the BLS website or the BLS Data Finder–links below. |
startyear |
The first year in your data set. |
endyear |
The last year in your data set. |
registrationKey |
The API key issued to you from the BLS website. |
catalog |
Series description information available only for certain data sets. |
calculations |
Returns year-over-year calculations if set to TRUE. |
annualaverage |
Returns an annual average if set to TRUE. |
... |
additional arguments |
A tibble from the BLS API.
## API Version 1.0 R Script Sample Code ## Single Series request df <- bls_api("LAUCN040010000000005") ## Not run: ## API Version 1.0 R Script Sample Code ## Multiple Series request with date params. df <- bls_api(c("LAUCN040010000000005", "LAUCN040010000000006"), startyear = "2010", endyear = "2012") ## API Version 1.0 R Script Sample Code ## Multiple Series request with date params. df <- bls_api(c("LAUCN040010000000005", "LAUCN040010000000006"), startyear = "2010", endyear = "2012") ## API Version 2.0 R Script Sample Code ## Multiple Series request with full params allowed by v2. df <- bls_api(c("LAUCN040010000000005", "LAUCN040010000000006"), startyear = "2010", endyear = "2012", registrationKey = "BLS_KEY", calculations = TRUE, annualaverage = TRUE, catalog = TRUE) ## End(Not run)
## API Version 1.0 R Script Sample Code ## Single Series request df <- bls_api("LAUCN040010000000005") ## Not run: ## API Version 1.0 R Script Sample Code ## Multiple Series request with date params. df <- bls_api(c("LAUCN040010000000005", "LAUCN040010000000006"), startyear = "2010", endyear = "2012") ## API Version 1.0 R Script Sample Code ## Multiple Series request with date params. df <- bls_api(c("LAUCN040010000000005", "LAUCN040010000000006"), startyear = "2010", endyear = "2012") ## API Version 2.0 R Script Sample Code ## Multiple Series request with full params allowed by v2. df <- bls_api(c("LAUCN040010000000005", "LAUCN040010000000006"), startyear = "2010", endyear = "2012", registrationKey = "BLS_KEY", calculations = TRUE, annualaverage = TRUE, catalog = TRUE) ## End(Not run)
A helper function to create a continuous date from Year and Period columns.
dateCast(api_df = NULL, dt_format = NULL)
dateCast(api_df = NULL, dt_format = NULL)
api_df |
The data frame you wish to cast a date column to. Be sure the data frame contains 'year' and 'period' columns as returned
by the |
dt_format |
A character string containing a valid date format. The default will return the ISO 8601 date format. |
A tibble from the source api_df
with an additional date column based on the date format given in dt_format
.
## Cast a date column to data frame returned by the bls_api() function. df <- bls_api("LAUCN040010000000005") %>% dateCast()
## Cast a date column to data frame returned by the bls_api() function. df <- bls_api("LAUCN040010000000005") %>% dateCast()
Returns a data frame that uses data from the Consumer Price Index (All Goods) to convert the value of a US Dollar [$1.00 USD] over time.
inflation_adjust(base_date = NA, ...)
inflation_adjust(base_date = NA, ...)
base_date |
= A string argument to represent the base month that you would like dollar values converted to. For example, if you want to see the value of a Jan. 2015 dollar in Jan. 2023, you would select "2015-01-01" as a base date and find Jan 2023 in the table. |
... |
additional arguments |
A tibble from the BLS API.
## Not run: ## Get historical USD values based on a dollar from Jan 2015. values <- inflation_adjust(base_year = "2015-01-01") ## End(Not run)
## Not run: ## Get historical USD values based on a dollar from Jan 2015. values <- inflation_adjust(base_year = "2015-01-01") ## End(Not run)
Returns the employment level. SeriesID: LNS12000000
If you installed a BLS_KEY with the set_bls_key()
function, it will detect it and use your key. This counts against your daily query limit.
quick_employed_level()
quick_employed_level()
A tibble from the BLS API.
## Not run: df <- quick_employed_level() ## End(Not run)
## Not run: df <- quick_employed_level() ## End(Not run)
Returns the "employment to population ratio." SeriesID: LNS12300000
If you installed a BLS_KEY with the set_bls_key()
function, it will detect it and use your key. This counts against your daily query limit.
quick_employed_rate()
quick_employed_rate()
A tibble from the BLS API.
## Not run: df <- quick_employed_rate() ## End(Not run)
## Not run: df <- quick_employed_rate() ## End(Not run)
Returns the civilian labor force level. SeriesID: LNS11000000.
If you installed a BLS_KEY with the set_bls_key()
function, it will detect it and use your key. This counts against your daily query limit.
quick_laborForce_level()
quick_laborForce_level()
A tibble from the BLS API.
## Not run: df <- quick_laborForce_level() ## End(Not run)
## Not run: df <- quick_laborForce_level() ## End(Not run)
Returns the civilian labor force participation rate. SeriesID: LNS11300000.
If you installed a BLS_KEY with the set_bls_key()
function, it will detect it and use your key. This counts against your daily query limit.
quick_laborForce_rate()
quick_laborForce_rate()
A tibble from the BLS API.
## Not run: df <- quick_laborForce_rate() ## End(Not run)
## Not run: df <- quick_laborForce_rate() ## End(Not run)
Returns the Total Nonfarm Payroll Employment, seasonally adjusted. BLS id CES0000000001.
If you installed a BLS_KEY with the set_bls_key()
function, it will detect it and use your key. This counts against your daily query limit.
quick_nonfarm_employed()
quick_nonfarm_employed()
A tibble from the BLS API.
## Not run: df <- quick_nonfarm_employed() ## End(Not run)
## Not run: df <- quick_nonfarm_employed() ## End(Not run)
Returns the unemployment level. SeriesID: LNS13000000.
If you installed a BLS_KEY with the set_bls_key()
function, it will detect it and use your key. This counts against your daily query limit.
quick_unemp_level()
quick_unemp_level()
A tibble from the BLS API.
## Not run: df <- quick_unemp_level() ## End(Not run)
## Not run: df <- quick_unemp_level() ## End(Not run)
Returns the "official" unemployment rate. That is, seasonally adjusted, 16 year and over, or the "U-3" rate. SeriesID: LNS14000000.
If you installed a BLS_KEY with the set_bls_key()
function, it will detect it and use your key. This counts against your daily query limit.
quick_unemp_rate()
quick_unemp_rate()
A tibble from the BLS API.
## Not run: df <- quick_unemp_rate() ## End(Not run)
## Not run: df <- quick_unemp_rate() ## End(Not run)
Search the internal series_id data set.
search_ids(keyword = NULL, periodicity_code = NULL, ...)
search_ids(keyword = NULL, periodicity_code = NULL, ...)
keyword |
The keyword you want to search. This can be a fuzzy search of multiple keywords. For example |
periodicity_code |
The period of time of the surveys you are interested in. This is usually monthly, quarterly or annually.
You can type full words or beginning letters. For example, |
... |
additional arguments |
A tibble from the the internal data set bls_ids
## Not run: # Search for monthly Unemployment Rates for Women ids <- search_ids(keyword = c("Unemployment Rate", "Women"), periodicity_code = "M") ## End(Not run)
## Not run: # Search for monthly Unemployment Rates for Women ids <- search_ids(keyword = c("Unemployment Rate", "Women"), periodicity_code = "M") ## End(Not run)
A utility function to run a tryCatch on a URL.
urlExists(target)
urlExists(target)
target |
url |
A logical of TRUE
or FALSE
.