authors: Peter Carbonetto, Gao Wang
In this analysis, we use the Divvy trip and station data to generate a map of Chicago.
We begin by loading a few packages, as well as some additional R functions implemented for this project. The repr
package is used to adjust the figure dimensions in the Jupyter notebook.
library(repr)
library(data.table)
library(ggplot2)
source("../code/functions.R")
divvy <- read.divvy.data()
We use the trip data to get the total number of departures by station. From these data, we create a "departures" column in the table.
divvy$stations <-
cbind(divvy$stations,
data.frame(departures = as.vector(table(divvy$trips$from_station_id))))
summary(divvy$stations$departures)
A plot of the Divvy stations by geographic location (latitude and longitude) traces the outlines of the City of Chicago and the Lake Michigan shore. Further, the location of the downtown is apparent by scaling the area of each circle by the number of trips.
The University of Chicago Divvy station is highlighted in red.
options(repr.plot.width = 4.5, repr.plot.height = 4.5)
divvy$stations <-
transform(divvy$stations,
at.uchicago = (name == "University Ave & 57th St"))
ggplot(divvy$stations,aes(x = longitude,
y = latitude,
fill = at.uchicago,
size = sqrt(departures))) +
geom_point(shape = 21,color = "white") +
scale_fill_manual(values = c("darkblue","red")) +
theme_minimal() +
theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank())
This is the version of Jupyter used to generate these results.
system("jupyter --version",intern = TRUE)
This is the version of R and the packages that were used to generate these results.
sessionInfo()
Exported from analysis/station-map.ipynb
committed by Peter Carbonetto on Wed Mar 7 03:16:30 2018 revision 8, c2d196c