load_bls_data | R Documentation |
Returns a data frame containing the specified Bureau of Labor Statistics data.
load_bls_data(
file_name,
series_id,
start_year = NULL,
end_year = NULL,
api_key = NULL,
fresh_start = FALSE
)
file_name |
character. The path and filename of an R serial data (.RDS) file to use for loading or saving data on disk. |
series_id |
character. The BLS series ID used to download data. |
start_year |
numeric. The first (earliest) year for which you want data for the |
end_year |
numeric. The last (most recent) year for which you want data for the |
api_key |
Your registred BLS API key, or |
fresh_start |
boolean. If true, will delete any existing data file specified by |
If the file specified by file_name
already exists, the data is loaded
from disk and returned. If the file does not exist, the series ID is used to download the
data from the BLS. The data is then saved to the file file_name
, and returned as
a data frame.
In addition to the data returned from the BLS's API, a new column date
is added,
with data class Date, and the data is sorted by date.
Both file_name
and series_id
should be passed as character strings, e.g.
file_name = "data/jobs_u.rds", series_id = "CEU0000000001"
.
A data frame
## Not run:
# Get all years of seasonally adjusted position reported by employers ("jobs report")
# and save to data/employer_jobs_s.rds
employer_jobs_s_df <- load_bls_data(file_name = "data/employer_jobs_s.rds",
series_id = "CES0000000001")
# Get the last decade of unadjusted employer-reported position
library(magrittr); library(lubridate)
my_start_date <- today() %>% year()
employer_decade_df <- load_bls_data(file_name = "data/last_decade_u.rds",
series_id = "CEU0000000001",
start_date = my_start_date)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.