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.
In [1]:
library(repr)
library(data.table)
library(ggplot2)
source("../code/functions.R")
As before, we use function read.divvy.data
to read the trip and station data from the CSV files.
In [2]:
divvy <- read.divvy.data()
In [3]:
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.
In [4]:
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())
In [5]:
system("jupyter --version",intern = TRUE)
This is the version of R and the packages that were used to generate these results.
In [6]:
sessionInfo()