diff --git a/DESCRIPTION b/DESCRIPTION index 7cc2aa0..3f7b277 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -16,8 +16,7 @@ URL: https://usmap.dev BugReports: https://github.com/pdil/usmap/issues Imports: rlang, - usmapdata, - utils + usmapdata (>= 0.1.2) Suggests: covr, ggplot2, diff --git a/NEWS.md b/NEWS.md index 3c7f041..c69709d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,16 @@ # usmap 0.6.3.9999 +### Improvements +* Replace local state and county FIPS files with `usmapdata::fips_data()`. + * Single source of truth for this data is now housed in `usmapdata`. + * Data will be updated in sync with shapefile updates. + +### Bug Fixes +* FIPS file change resolves issue with Valdez-Cordova Census Area in Alaska, see [Issue #72](https://github.com/pdil/usmap/issues/72). +### Technical Changes +* Resolve all code-linting warnings. +* Increase test coverage to 100%. # usmap 0.6.3 Released Saturday, October 21, 2023. @@ -36,7 +46,7 @@ Released Sunday, February 27, 2022. * Extract map data frame to external [usmapdata](https://github.com/pdil/usmapdata) package to reduce `usmap` package size, see [Issue #39](https://github.com/pdil/usmap/issues/39). * All existing functions (including `us_map()`) should continue to work as usual. * Add data format examples for `plot_usmap` to "Mapping" vignette, see [Issue #42](https://github.com/pdil/usmap/issues/42). - + ### Bug Fixes * Fix CRS warnings, see [Issue #40](https://github.com/pdil/usmap/issues/40). * Fix `plot_usmap()` issue when provided data has `"values"` column, see [Issue #48](https://github.com/pdil/usmap/issues/48) and [this Stack Overflow question](https://stackoverflow.com/questions/61111024/trouble-using-plot-usmap-function-in-usmap-package). @@ -71,7 +81,7 @@ Released Friday, September 13, 2019. * Ability to exclude counties and states with new `exclude` parameter in `us_map`, `map_with_data`, and `plot_usmap`, see [Issue #19](https://github.com/pdil/usmap/issues/19). * New function (`usmap_transform`) to transform longitude/latitude point data frames into coordinate reference system that matches the plotted map, see [Issue #21](https://github.com/pdil/usmap/issues/21). * Also includes `usmap_crs()` to easily access the coordinate reference system used by the package. - + ### Improvements * In the data frames provided by `us_map()`, `long` and `lat` have been renamed to `x` and `y`, respectively, see [Issue #16](https://github.com/pdil/usmap/issues/16). * This should not affect the behavior of `plot_usmap()` but will be a breaking change for any code that relies on `us_map()`. diff --git a/R/fips.R b/R/fips.R index c76625d..3da978d 100644 --- a/R/fips.R +++ b/R/fips.R @@ -52,8 +52,7 @@ #' @export fips <- function(state, county = c()) { if (missing(state) && missing(county)) { - df <- usmapdata::fips_data() - return(sprintf("%02d", df$fips)) + return(usmapdata::fips_data()$fips) } state_ <- tolower(state) @@ -66,10 +65,8 @@ fips <- function(state, county = c()) { fips2 <- c(df$fips, df$fips) result <- fips2[match(state_, c(abbr, full))] - - formatted_result <- sprintf("%02d", result) - formatted_result[formatted_result == "NA"] <- NA - formatted_result + result[result == "NA"] <- NA + result } else { if (length(state_) > 1) { stop("`county` parameter cannot be used with multiple states.") @@ -99,7 +96,7 @@ fips <- function(state, county = c()) { stop(paste0(county, " are not valid counties in ", state, ".\n")) } } else { - sprintf("%05d", result) + result } } } diff --git a/man/set_sp_evolution_status.Rd b/man/set_sp_evolution_status.Rd deleted file mode 100644 index 30a8f1d..0000000 --- a/man/set_sp_evolution_status.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/transform.R -\name{set_sp_evolution_status} -\alias{set_sp_evolution_status} -\title{Set sp evolution status} -\usage{ -set_sp_evolution_status() -} -\description{ -Sets the \code{sp} evolution status to "2" to -force usage of \code{sf} instead of \code{rgdal} -which is being retired. - -This can be removed in the future when the evolution status -is set to >= 2 by default in \code{sf}. -} -\keyword{internal} diff --git a/tests/testthat/test-transform.R b/tests/testthat/test-transform.R index a27e2f4..5666999 100644 --- a/tests/testthat/test-transform.R +++ b/tests/testthat/test-transform.R @@ -111,9 +111,3 @@ test_that("error occurs for data with non-numeric columns", { expect_error(usmap_transform(invalid_data2)) expect_error(usmap_transform(invalid_data3)) }) - -test_that("sp evolution status is set correctly", { - sp::set_evolution_status(1L) - usmap_transform(data.frame(lon = 0, lat = 0)) - expect_equal(sp::get_evolution_status(), 2L) -})