Skip to content

Instantly share code, notes, and snippets.

@1beb
Created June 24, 2011 17:15
Show Gist options
  • Save 1beb/1045230 to your computer and use it in GitHub Desktop.
Save 1beb/1045230 to your computer and use it in GitHub Desktop.
Part IIV: ggplot2 Introduction Mapping Example
## Title: ggplot2 Introduction: Plotting Maps
## Description: This line by line analysis, provides an introduction to ggplot2. Mapping.
## Created by: Brandon Bertelsen: Research Manager, Credo Consulting Inc.
# install.packages(maptools)
library(maptools)
library(ggplot2)
# Must allow for licensing
gpclibPermit()
# Fedoral Electoral Districts Courtesy of http://geobase.ca/geobase/en/data/admin/fed/description.html
shape<-readShapeSpatial("R:/root/dev/ggplot2 Introduction/fed308_a.shp")
# Fortify
x <- fortify(shape, region="FED_NUM")
# Subset holes
ggplot(x, aes(long, lat)) + geom_path()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment