Skip to content

Commit

Permalink
# blscrapeR 4.0.0
Browse files Browse the repository at this point in the history
## Bug Fixes

* Fixed API call 403 issue with `inflation_adjust()` function.

## Features

* Added `county_fips()` function to list county FIPS codes for a specific state.

## Data

* Updated all internal data sets.

## Removed

* Removed all mapping functions and data, recommend to use the `tigris` package for these activities.
* Removed qcew_api function.
  • Loading branch information
keberwein committed Mar 13, 2024
1 parent 81337a8 commit 99b8144
Show file tree
Hide file tree
Showing 49 changed files with 424 additions and 8,845 deletions.
2 changes: 2 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@
^cran-comments\.md$
^appveyor\.yml$
^CRAN-SUBMISSION$
^revdep$
^\.github$
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
50 changes: 50 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: R-CMD-check

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- {os: macos-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check

- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
10 changes: 4 additions & 6 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
Package: blscrapeR
Type: Package
Title: An API Wrapper for the Bureau of Labor Statistics (BLS)
Version: 3.2.2
Title: An API Wrapper for the United States Bureau of Labor Statistics
Version: 4.0.0
Authors@R: person("Kris", "Eberwein", email = "[email protected]",
role = c("aut", "cre"))
Description: Scrapes various data from <https://www.bls.gov/>. The U.S. 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.
Description: Scrapes various data from United States Bureau of Labor Statistics. 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.
Depends: R (>= 3.5.0)
Imports:
httr,
jsonlite,
ggplot2,
magrittr,
utils,
stats,
grDevices,
dplyr,
purrr,
tibble,
Expand All @@ -27,4 +25,4 @@ URL: https://github.com/keberwein/blscrapeR
BugReports: https://github.com/keberwein/blscrapeR/issues
LazyData: true
VignetteBuilder: knitr
RoxygenNote: 7.2.1
RoxygenNote: 7.2.3
20 changes: 5 additions & 15 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,10 @@
export("%<>%")
export("%>%")
export(bls_api)
#export(bls_map_county)
#export(bls_map_state)
export(county_fips)
export(dateCast)
export(firstupper)
#export(get_bls_county)
#export(get_bls_state)
export(inflation_adjust)
#export(map_bls)
export(qcew_api)
export(quick_employed_level)
export(quick_employed_rate)
export(quick_laborForce_level)
Expand All @@ -22,12 +17,10 @@ export(quick_unemp_rate)
export(search_ids)
export(set_bls_key)
export(urlExists)
import(datasets)
import(ggplot2)
import(grDevices)
import(utils)
importFrom(dplyr,arrange)
importFrom(dplyr,filter)
importFrom(dplyr,mutate)
importFrom(dplyr,pull)
importFrom(dplyr,rename)
importFrom(dplyr,select)
importFrom(httr,POST)
Expand All @@ -38,15 +31,12 @@ importFrom(magrittr,"%<>%")
importFrom(magrittr,"%>%")
importFrom(purrr,map)
importFrom(purrr,map_chr)
importFrom(purrr,map_int)
importFrom(purrr,map_lgl)
importFrom(stats,aggregate)
importFrom(stats,na.omit)
importFrom(stats,lag)
importFrom(stringr,str_detect)
importFrom(stringr,str_to_title)
importFrom(stringr,str_trim)
importFrom(tibble,as_tibble)
importFrom(utils,capture.output)
importFrom(utils,download.file)
importFrom(utils,read.csv)
importFrom(utils,read.table)
importFrom(utils,write.table)
20 changes: 20 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
# blscrapeR 4.0.0

## Bug Fixes

* Fixed API call 403 issue with `inflation_adjust()` function.

## Features

* Added `county_fips()` function to list county FIPS codes for a specific state.

## Data

* Updated all internal data sets.

## Removed

* Removed all mapping functions and data, recommend to use the `tigris` package for these activities.
* Removed qcew_api function.


# blscrapeR 3.2.2

## Bug Fixes
Expand Down
2 changes: 0 additions & 2 deletions R/bls_api.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
#' @importFrom purrr map
#' @importFrom tibble as_tibble
#' @export bls_api
#' @seealso \url{https://www.bls.gov/data/}
#' @seealso \url{https://beta.bls.gov/dataQuery/search}
#' @return A tibble from the BLS API.
#' @examples
#'
Expand Down
43 changes: 43 additions & 0 deletions R/county_fips.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#' @title Return a dataframe of county FIPS codes by state.
#' @description Returns a data frame that uses data from the US Census FIPS code list.
#' @param state = A string containing a standard state short abbreviation, i.e. FL, WA, OH, etc.
#' @param ... additional arguments
#' @importFrom stats aggregate
#' @importFrom dplyr filter
#' @importFrom tibble as_tibble
#' @importFrom stringr str_trim
#' @export county_fips
#' @return A tibble from the BLS API.
#' @examples
#' \dontrun{
#' ## Get historical USD values based on a 2010 dollar.
#' values <- county_fips(state = "FL")
#' }
#'

county_fips <- function(state, ...) {
# Define a list of valid state abbreviations
valid_states <- c("AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DE", "FL", "GA",
"HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MD",
"MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ",
"NM", "NY", "NC", "ND", "OH", "OK", "OR", "PA", "RI", "SC",
"SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY",
"AS", "DC", "FM", "GU", "MH", "MP", "PW", "PR", "VI")

# Convert the input to uppercase and trim white space
state_in <- toupper(str_trim(state))

# Check if the input is a valid state abbreviation
if (!(state_in %in% valid_states)) {
stop("Invalid state abbreviation. Please provide a valid US state or territory.")
}

fips_in <- blscrapeR::county_fips

fips <- fips_in %>% filter(state == state_in) %>% tibble::as_tibble()

return(fips)
}



122 changes: 19 additions & 103 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#'
#'
#' @usage data(series_ids)
#' @note Last updated 2019-12-15
#' @note Last updated 2024-03-13
"series_ids"


Expand All @@ -28,7 +28,7 @@
#'
#'
#' @usage data(area_titles)
#' @note Last updated 2016-09-30
#' @note Last updated 2024-03-13
#' @format A data frame with 4723 rows and 2 variables
"area_titles"

Expand All @@ -50,29 +50,11 @@
#'
#'
#' @usage data(county_fips)
#' @note Last updated 2016-05-27
#' @note Last updated 2024-03-13
#' @format A data frame with 3235 rows and 5 variables
"county_fips"


#' Dataset containing NIACS codes for industry lookups.
#'
#' Built-in dataset to look up industries by NAICS code.
#' To access the data directly, issue the command \code{niacs)}.
#' \itemize{
#' \item \code{industry_code}: Industry code
#' \item \code{industry_title}: Industry title
#' }
#'
#' @docType data
#' @keywords internal
#'
#'
#' @usage data(niacs)
#' @note Last updated 22019-12-15
#' @format A data frame with 2469 rows and 2 variables
"niacs"

#' Dataset containing NIACS codes for industry lookups.
#'
#' Built-in dataset to look up industries by NAICS code.
Expand All @@ -87,7 +69,7 @@
#'
#'
#' @usage data(naics)
#' @note Last updated 2019-12-15
#' @note Last updated 2024-03-13
#' @format A data frame with 2469 rows and 2 variables
"naics"

Expand All @@ -107,7 +89,7 @@
#'
#'
#' @usage data(size_titles)
#' @note Last updated 2016-09-30
#' @note Last updated 2024-03-13
#' @format A data frame with 10 rows and 2 variables
"size_titles"

Expand All @@ -130,93 +112,27 @@
#'
#'
#' @usage data(state_fips)
#' @note Last updated 2016-05-27
#' @note Last updated 2024-03-13
#' @format A data frame with 57 rows and 4 variables
"state_fips"


#' Dataset with the lat. / long. of county FIPS codes used for mapping.
#'
#' Built-in dataset for use with the \code{bls_map_county()} function.
#' To access the data directly, issue the command \code{data(county_map_merc)}.
#'
#' @title Dataset for mapping U.S. counties with a Mercator projection
#' @description A fortified data set that includes U.S. counties and is suitable for making maps with \code{ggplot2}.
#' The county FIPS codes and boundary lines from the most recent TIGER release from the U.S. Census Bureau.
#'
#' \itemize{
#' \item \code{long}: County longitude
#' \item \code{lat}: County latitude
#' \item \code{order}: Polygon order
#' \item \code{hole}: hole
#' \item \code{piece}: Polygon piece
#' \item \code{id}: FIPS Code
#' \item \code{group}: group
#' }
#'
#' @docType data
#' @keywords datasets
#'
#' @name county_map_data
#' @usage data(county_map_merc)
#' @note Last updated 2017-01-26
#' @format A data frame with 55,413 rows and 7 variables
"county_map_merc"


#' Dataset with the lat. / long. of county FIPS codes used for mapping.
#'
#' Built-in dataset for use with the \code{bls_map_county()} function.
#' To access the data directly, issue the command \code{data(county_map_data)}.
#'
#' @title Dataset for mapping U.S. counties
#' @description A fortified data set that includes U.S. counties and is suitable for making maps with \code{ggplot2}.
#' The county FIPS codes and boundary lines from the most recent TIGER release from the U.S. Census Bureau.
#' Dataset containing All items in U.S. city average, all urban consumers, seasonally adjusted CUSR0000SA0.
#'
#' Built-in dataset to look CPI values by month.
#' Includes recent and historical CPI values.
#' To access the data directly, issue the command \code{cu_main)}.
#' \itemize{
#' \item \code{long}: County longitude
#' \item \code{lat}: County latitude
#' \item \code{order}: Polygon order
#' \item \code{hole}: hole
#' \item \code{piece}: Polygon piece
#' \item \code{id}: FIPS Code
#' \item \code{group}: group
#' \item \code{date}: Date in yyyy-mm-dd format
#' \item \code{period}: Monthly period
#' \item \code{year}: CPI year
#' \item \code{value}: CPI value
#' }
#'
#' @docType data
#' @keywords datasets
#'
#' @name county_map_data
#' @usage data(county_map_data)
#' @note Last updated 2017-01-26
#' @format A data frame with 55,413 rows and 7 variables
"county_map_data"


#' Dataset with the lat. / long. of county FIPS codes used for mapping.
#'
#' Built-in dataset for use with the \code{bls_map_state()} function.
#' To access the data directly, issue the command \code{datastate_map_data)}.
#' @keywords internal
#'
#' @title Dataset for mapping U.S. states
#' @description A fortified data set that includes U.S. states and is suitable for making maps with \code{ggplot2}.
#' The county FIPS codes and boundary lines from the most recent TIGER release from the U.S. Census Bureau.
#'
#' \itemize{
#' \item \code{long}: State longitude
#' \item \code{lat}: State latitude
#' \item \code{order}: Polygon order
#' \item \code{hole}: hole
#' \item \code{piece}: Polygon piece
#' \item \code{id}: FIPS Code
#' \item \code{group}: group
#' }
#'
#' @docType data
#' @keywords datasets
#'
#' @name state_map_data
#' @usage data(state_map_data)
#' @note Last updated 2017-01-26
#' @format A data frame with 13,660 rows and 7 variables
"state_map_data"
#' @usage data(cu_main)
#' @note Last updated 2024-03-24
#' @format A data frame with 926 rows and 4 variables
"cu_main"
Loading

0 comments on commit 99b8144

Please sign in to comment.