-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
13a02b9
commit 05f0b12
Showing
3 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#' Filter a NHGIS data frame by a state FIPS and county FIPS numbers | ||
#' | ||
#' By default, filter to counties in the Baltimore metro area. | ||
#' | ||
#' @param values Optional vector of GISJOIN values. state_fips and county_fips | ||
#' are ignored if this is supplied. | ||
#' @keywords internal | ||
filter_gisjoin <- function(data, | ||
state = NULL, | ||
county = NULL, | ||
values = NULL, | ||
gisjoin_col = "GISJOIN") { | ||
if (is.null(values)) { | ||
check_installed("tigris") | ||
|
||
if (!is.null(state) && is.null(county)) { | ||
state <- tigris:::validate_state(state = state, multiple = TRUE) | ||
values <- paste0("G", state_fips, "0") | ||
} else { | ||
state <- tigris:::validate_state(state = state) | ||
county <- tigris:::validate_state(state = state, county = county, multiple = TRUE) | ||
values <- paste0("G", state, "0", county, "0") | ||
} | ||
} | ||
|
||
dplyr::filter(data, .data[[gisjoin_col]] %in% values) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.