Skip to content

Instantly share code, notes, and snippets.

@ramnathv
Created March 5, 2011 19:34
Show Gist options
  • Save ramnathv/856648 to your computer and use it in GitHub Desktop.
Save ramnathv/856648 to your computer and use it in GitHub Desktop.
# Load Data
poly = readShapeSpatial('1_data/maps/Precincts.shp');
df = read.csv('1_data/precincts.csv');
# Clean Data
df = df[,-grep('count', names(df))];
names(df) = sub('_pct', '', names(df));
# Plot Choropleth
choro1 = plotChoropleth(.poly = poly, .df = df,
id1 = list('WARD', 'PRECINCT'),
id2 = list('ward', 'precinct')
field = 'emanuel',
title = 'Chicago Mayoral Elections 2011',
legtitle = 'Emanuel (% Votes)'
colpal = 'Blues', n = 5, style = 'pretty') +
opts(legend.position = c(0.25, 0.35)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment