Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to only display certain states in county map #11

Closed
pdil opened this issue Sep 6, 2018 · 0 comments
Closed

Add ability to only display certain states in county map #11

pdil opened this issue Sep 6, 2018 · 0 comments
Assignees
Labels

Comments

@pdil
Copy link
Owner

@pdil pdil commented Sep 6, 2018

The county map should be able to display only counties in certain states using the include parameter.

For example,

plot_usmap("counties", include = c("NJ", "PA", "NY"))

This can be fixed at this location in usmap.R:

if (length(include) > 0) {
  if (regions_ %in% c("counties", "county")) {
    df <- df[df$fips %in% include, ]
  } else {
    df <- df[df$full %in% include | df$abbr %in% include | df$fips %in% include, ]
  }
}

The body of the if statement should be changed to:

if (length(include) > 0) {
  df <- df[df$full %in% include | df$abbr %in% include | df$fips %in% include, ]
}

This should work because both the county and state map files have columns fips, full, and abbr.

Updating this function also has the added side-effect of allowing users to specify any combination of states and counties to include using either FIPS code, state abbreviation, state name, or a mixture of the three.

@pdil pdil added the enhancement label Sep 6, 2018
@pdil pdil self-assigned this Sep 6, 2018
@pdil pdil closed this in 280108c Sep 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.