keberwein / blscrapeR

A tool to gather, analyze and visualize data from the Bureau of Labor Statistics (BLS) API. Functions include segmentation, geographic analysis and visualization.
https://github.com/keberwein/blscrapeR
Other
112 stars 11 forks source link

Limits on series id? #33

Closed cdeterman closed 2 years ago

cdeterman commented 2 years ago

I am trying to experiment with different series id values using the BLS documentation found here. I am particularly interested in the 'State and Area employment, hours, and earnings. However, even the sample series id fails to pull with the following minor change.

example from BLS

all_earnings <- bls_api(seriesid="SMU197802023800001",
                        startyear=2019)

However, if I modify the first two numeric values to 55 indicating Wisconsin as opposed to Iowa I just get the following indicating what seems to be success and failure.

wis_earnings <- bls_api(seriesid="SMU557802023800001",
                        startyear=2019)
The API requires both a start and end year.
The endyear argument has automatically been set to 2021.
REQUEST_SUCCEEDED
Warning message:
Unknown or uninitialised column: `value`.

This results in a dataframe that is empty. Any insight would be appreciated.

cdeterman commented 2 years ago

Furthermore, the SIC example series id fails, with the same results as above on its own, with the following from here.

df <- bls_api(seriesid="SAS0800002000011", 
              startyear = 2019)
keberwein commented 2 years ago

The empty data frame is returned due to the code being malformated. In the first example we are looking for Employment statistics for Construction Workers in Des-Moins. That code is "SMU19197802023800001" the code you provided is missing two zeros, I assume you omitted the super-sector code. The BLS documentation you linked has the correct code.

The "BLS Data Finder" is a useful tool when trying to drill down to specific regions and occupations.

So, this works as expected.

all_earnings <- bls_api(seriesid="SMU19197802023800001", startyear=2019)

keberwein commented 2 years ago

A high-priority ticket has been created to address this issue in the next version. https://github.com/keberwein/blscrapeR/issues/35

keberwein commented 2 years ago

Other functionality that was added a while ago. There is a series_id function that will do a "fuzzy search" for certian things. Code below.

ids <- search_ids(keyword = c("Earnings", "Software", "Women"))
head(ids)