Mexico City’s Metro Statistics

June 24, 2012
By

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

I used R and ggplot2 to make a bubble map of Mexico City’s Metro passenger count from January to February 2012. The statistics are stunning, some stations for example Indios Verdes, reached 10 million passengers in jus three months. You can see the code below and get the data for the project here.

```#Statistical analysis of Mexico City's Metro
#Author Jose Gonzalez
#Website www.jose-gonzalez.org

library(ggplot2)
data(diamonds)
library(RColorBrewer)
library(foreign)
afluencia afluencia[1:10,]

# Simple Bubble plot
#Declare factor to choose colors
text(data\$longitude, data\$latitude, data\$estacion, cex=0.3)

#### ggplot
#Define layer
ggplot() +
layer(
data = afluencia, mapping = aes(x = longitude, y = latitude, colour=factor(linea)),
geom = "point")

#Full map
r r #print map
rc rc # print map

## Manually adjust the colors for each line
rc + scale_colour_manual(values = cols) + geom_text(aes(label = estacion), hjust=-0.1, vjust=0)

## Map inset focus on Downtown
rc + scale_colour_manual(values = cols) + geom_text(aes(label = estacion), hjust=-0.1, vjust=0) + coord_cartesian(xlim=c(-99.15, -99.10), ylim=c(19.40, 19.45))

```

The post Mexico City’s Metro Statistics appeared first on Jose Gonzalez .org.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.