Mexico City’s Metro Statistics

June 24, 2012

(This article was first published on Jose Gonzalez .org » R, and kindly contributed to R-bloggers)

Bubble map of the Metro

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

## Load packages
#Read data form excel
afluencia afluencia[1:10,]

# Simple Bubble plot
#Declare factor to choose colors
ff radius mycolor symbols(data$longitude, data$latitude, circles=radius, inches=0.1, fg=ff, bg="white", xlab="Longitude", ylab="Latitude")
text(data$longitude, data$latitude, data$estacion, cex=0.3)

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

#Full map
r r #print map
##Add customized colors
rc rc # print map

## Manually adjust the colors for each line
cols ## Add text labels
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.

To leave a comment for the author, please follow the link and comment on their blog: Jose Gonzalez .org » R. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)