This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
Here is the code to split Divvy trip data into all of the trips leaving Fullerton. We then make an interactive map:
library(knitr)
library(scales)
library(rCharts)
data <- read.csv("Divvy_Trips_2014-Q3-07.csv")
stations <- read.csv("Divvy_Stations_2014-Q3Q4.csv")
fullerton <- subset(data, from_station_name == "Sheffield Ave & Fullerton Ave")
fullerton.dest <- data.frame(table(fullerton$to_station_name)) # Makes a frequency table for all of the departures from Sheffield & Fullerton
m1 <- merge(fullerton.dest, stations, by.x = "Var1", by.y = "name")
## Create a data frame of the frequency of rides departing Fullerton to various stations
fulldepart <- subset(m1, Freq > 0)
# Now map it
map <- Leaflet$new()
map$setView(c(41.925271, -87.653732), zoom = 12) #centers on Fullerton and Sheffield
map$tileLayer(provider = 'Stamen.TonerLite')
for (i in 1:nrow(fulldepart)) {
map$marker(c(fulldepart[i, "latitude"], fulldepart[i, "longitude"]), bindPopup = as.factor(fulldepart[i, "Freq"]))
}
We will now embed the plots:
Note that the echo = FALSE
parameter was added to the code chunk to prevent printing of the R code that generated the plot.
Here are the summary statistics for frequency of travel from Fullerton:
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 1.00 2.00 4.50 10.79 13.00 139.00