Skip to content

Instantly share code, notes, and snippets.

@ramhiser
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ramhiser/8834016 to your computer and use it in GitHub Desktop.
Save ramhiser/8834016 to your computer and use it in GitHub Desktop.
Creates data.frame of census regions by state
# For info about census regions, see:
# http://en.wikipedia.org/wiki/List_of_regions_of_the_United_States#Census_Bureau-designated_regions_and_divisions
# Region - Northeast
# Division - New England
new_england <- data.frame(
region = "Northeast",
division = "New England",
state = c("ME", "NH", "VT", "MA", "RI", "CT")
)
# Division - Mid-Atlantic
mid_atlantic <- data.frame(
region = "Northeast",
division = "Mid-Atlantic",
state = c("NY", "PA", "NJ")
)
# Region - Midwest
# Division - East North Central
east_north_central <- data.frame(
region = "Midwest",
division = "East North Central",
state = c("WI", "MI", "IL", "IN", "OH")
)
# Division - West North Central
west_north_central <- data.frame(
region = "Midwest",
division = "West North Central",
state = c("MO", "ND", "SD", "NE", "KS", "MN", "IA")
)
# Region - South
# Division - South Atlantic
south_atlantic <- data.frame(
region = "South",
division = "South Atlantic",
state = c("DE", "MD", "DC", "VA", "WV", "NC", "SC", "GA", "FL")
)
# Division - East South Central
east_south_central <- data.frame(
region = "South",
division = "East South Central",
state = c("KY", "TN", "MS", "AL")
)
# Division - West South Central
west_south_central <- data.frame(
region = "South",
division = "West South Central",
state = c("OK", "TX", "AR", "LA")
)
# Region - West
# Division - Mountain
mountain <- data.frame(
region = "West",
division = "Mountain",
state = c("ID", "MT", "WY", "NV", "UT", "CO", "AZ", "NM")
)
# Division - Pacific
pacific <- data.frame(
region = "West",
division = "Pacific",
state = c("AK", "WA", "OR", "CA", "HI")
)
census_regions <- rbind(new_england,
mid_atlantic,
east_north_central,
west_north_central,
south_atlantic,
east_south_central,
west_south_central,
mountain,
pacific
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment