Explore Map Partition Using CLustering with Interaction Using R Shiny

Mr Jim
May 23, 2018

Apportionment of Congressional Districts by State

Background

The number of US congressional districts are allocated on a state by state basis according to the total number of house seats fixed at 435 and the result of the US census conducted every ten years.

The purpose is to consider how to do absolutely fair congressional district apportionment using clustering and plotting capability of R. It is the antithesis of gerrymander.

Approach

Consider K-means clustering and heirarchical clustering. This is an exploration of it. The application uses heirarchical clustering.

The user interace provides option for user to enter:

  • A state
  • Clustering method parameter
  • Clusterlink parameter
    used in the hclust routine.

The result is drawn on a map and on a dendro plot.

Environment, Data and Data Preparation

These libraries are used:

  • 'xlsx','plyr','amap','tmap','maptools'

Data Sets

Data Preparation

  • Data sets merge into the shape files
  • After the shape file data set is built, an extract is done to run the clustering
  • A masster Shape Data Frame is built with from the original tiger file, apportionment data and population data
  • FIPS links Shape to population
  • State name links shape and apportionment
  • At runtime the master data set if filtered on state name.

Shiny Interaction

Setup

  • THe form has two frames, sidebar frame and main frame.
  • The sidebar frame has drop downs for
    • State
    • Cluster Method Param
    • Cluster Link Param
  • The main Frame
    • Report the selected option
    • Plots Colorpleth State map of counties
    • Plots Heirarchical dendro plot with threshold and boxing.

Plotting

knitr::include_graphics('screen_shot.png',  dpi = NULL)

plot of chunk unnamed-chunk-1

end