Skip to content

Commit

Permalink
Update documentation and templates (#96)
Browse files Browse the repository at this point in the history
* Added separate package documentation file to standardize with
`usmapdata`.
  * `usethis::use_package_doc()` was utilized
* Updated issue and pull request templates.
* Set explanatory notes to be commented so they don't appear in the body
of the issue/pull request.
  • Loading branch information
pdil authored Mar 17, 2024
2 parents dd03ff9 + 64c0651 commit 486979f
Show file tree
Hide file tree
Showing 15 changed files with 84 additions and 67 deletions.
27 changes: 15 additions & 12 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,32 @@ assignees: ''
---

**Describe the bug**
A clear and concise description of what the bug is.
<!-- A clear and concise description of what the bug is. -->


**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
<!--
List the steps to reproduce the behavior.
Include as much detail as possible including sample code and sample data, if applicable.
-->



**Expected behavior**
A clear and concise description of what you expected to happen.
<!-- A clear and concise description of what you expected to happen. -->


**Environment (please complete the following information):**
**Environment <!-- (please complete the following information) -->:**
- Platform: [e.g. macOS, Windows, Linux]
- `version` output:
```
```
- `sessionInfo()` output:
```
```


**Additional context**
Add any other context about the problem here.
<!-- Add any other context about the problem here. -->
12 changes: 8 additions & 4 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ assignees: ''
---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->


**Describe the solution you'd like**
A clear and concise description of what you want to happen.
<!-- A clear and concise description of what you want to happen. -->


**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
<!-- A clear and concise description of any alternative solutions or features you've considered. -->


**Additional context**
Add any other context or screenshots about the feature request here.
<!-- Add any other context or screenshots about the feature request here. -->

9 changes: 0 additions & 9 deletions .github/PULL_REQUEST_TEMPLATE/pull_request.md

This file was deleted.

20 changes: 20 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

### Changes
<!-- List the changes made by the pull request and rationale where applicable -->
*
*
*

### Notes
<!--
List any other related notes,
e.g. how to test the changes or any known issues
-->
*
*
*

<!-- Include the issue number here if applicable -->
resolves #

@pdil
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* Add citation information to README, see [Issue #86](https://github.com/pdil/usmap/issues/86).
* Update map theme to work with new legend behavior in [ggplot2 3.5.0](https://www.tidyverse.org/blog/2024/02/ggplot2-3-5-0-legends/#placement).
* Update provided population and poverty (county & state) data sets, see [Issue #88](https://github.com/pdil/usmap/issues/88).
* Previous data sets from 2015 and 2014, respectively have been updated to 2022 and 2021 versions, respectively.
* The main change (besides numerical values) is that Connecticut now has the correct FIPS codes in the 2022 county population data set. See [this Federal Register document](https://www.federalregister.gov/documents/2022/06/06/2022-12063/change-to-county-equivalents-in-the-state-of-connecticut) for more information. The 2021 county data does not include CT updates yet since the new FIPS codes were not made effective until 2022. Poverty data for 2022 is not available yet so the most recently available data from 2021 is included for now.

### Documentation
* Replace `size` with `linewidth` in `plot_usmap()` documentation, see [Issue #89](https://github.com/pdil/usmap/issues/89).
Expand Down
34 changes: 34 additions & 0 deletions R/us-map.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#' Retrieve US map data
#'
#' @param regions The region breakdown for the map, can be one of
#' (\code{"states"}, \code{"state"}, \code{"counties"}, \code{"county"}).
#' The default is \code{"states"}.
#' @param include The regions to include in the resulting map. If \code{regions} is
#' \code{"states"}/\code{"state"}, the value can be either a state name, abbreviation or FIPS code.
#' For counties, the FIPS must be provided as there can be multiple counties with the
#' same name. If states are provided in the county map, only counties in the included states
#' will be returned.
#' @param exclude The regions to exclude in the resulting map. If \code{regions} is
#' \code{"states"}/\code{"state"}, the value can be either a state name, abbreviation or FIPS code.
#' For counties, the FIPS must be provided as there can be multiple counties with the
#' same name. The regions listed in the \code{include} parameter are applied first and the
#' \code{exclude} regions are then removed from the resulting map. Any excluded regions
#' not present in the included regions will be ignored.
#'
#' @seealso [usmapdata::us_map()] of which this function is a wrapper for.
#'
#' @return A data frame of US map coordinates divided by the desired \code{regions}.
#'
#' @examples
#' str(us_map())
#'
#' df <- us_map(regions = "counties")
#' west_coast <- us_map(include = c("CA", "OR", "WA"))
#'
#' south_atl_excl_FL <- us_map(include = .south_atlantic, exclude = "FL")
#' @export
us_map <- function(regions = c("states", "state", "counties", "county"),
include = c(),
exclude = c()) {
usmapdata::us_map(regions = regions, include = include, exclude = exclude)
}
37 changes: 3 additions & 34 deletions R/usmap.R → R/usmap-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,37 +71,6 @@
#' @name usmap
"_PACKAGE"

#' Retrieve US map data
#'
#' @param regions The region breakdown for the map, can be one of
#' (\code{"states"}, \code{"state"}, \code{"counties"}, \code{"county"}).
#' The default is \code{"states"}.
#' @param include The regions to include in the resulting map. If \code{regions} is
#' \code{"states"}/\code{"state"}, the value can be either a state name, abbreviation or FIPS code.
#' For counties, the FIPS must be provided as there can be multiple counties with the
#' same name. If states are provided in the county map, only counties in the included states
#' will be returned.
#' @param exclude The regions to exclude in the resulting map. If \code{regions} is
#' \code{"states"}/\code{"state"}, the value can be either a state name, abbreviation or FIPS code.
#' For counties, the FIPS must be provided as there can be multiple counties with the
#' same name. The regions listed in the \code{include} parameter are applied first and the
#' \code{exclude} regions are then removed from the resulting map. Any excluded regions
#' not present in the included regions will be ignored.
#'
#' @seealso [usmapdata::us_map()] of which this function is a wrapper for.
#'
#' @return A data frame of US map coordinates divided by the desired \code{regions}.
#'
#' @examples
#' str(us_map())
#'
#' df <- us_map(regions = "counties")
#' west_coast <- us_map(include = c("CA", "OR", "WA"))
#'
#' south_atl_excl_FL <- us_map(include = .south_atlantic, exclude = "FL")
#' @export
us_map <- function(regions = c("states", "state", "counties", "county"),
include = c(),
exclude = c()) {
usmapdata::us_map(regions = regions, include = include, exclude = exclude)
}
## usethis namespace: start
## usethis namespace: end
NULL
2 changes: 1 addition & 1 deletion man/us_map.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/usmap.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion tests/testthat/test-fips-info.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

test_that("all states returned when no FIPS specified", {
expect_equal(fips_info()$fips, fips())
})
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-fips.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

test_that("all FIPS codes returned when no state specified", {
expect_equal(fips(),
c("02", "01", "05", "04", "06", "08", "09", "11",
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-join-data.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

state_data <- data.frame(fips = c("01", "02", "04"), values = c(3, 5, 10))
county_data <- data.frame(fips = c("01001", "01003", "01005"), values = c(3, 5, 10))

Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-plot.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

test_that("dependencies are verified", {
expect_package_error("ggplot2", plot_usmap())
})
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-transform.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

test_that("data frame with AK and HI points is transformed", {
data <- data.frame(
lon = c(-74.01, -95.36, -118.24, -87.65, -134.42, -157.86),
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-usmap.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

test_that("state data frame is returned", {
data <- us_map()

Expand Down

0 comments on commit 486979f

Please sign in to comment.