---
title: "Ford Go Bike API"
output:
html_notebook: default
pdf_document: default
word_document: default
---
[General Bikeshare Feed Specification (GBFS)](https://github.com/NABSA/gbfs/blob/master/gbfs.md)
R Package that connects to the GBFS API
[R gbfs](https://github.com/ds-civic-data/gbfs)
North American Bike Share Association
[NBSA](https://github.com/NABSA) [system.csv](https://github.com/NABSA/gbfs/blob/master/systems.csv)
```{r, eval=FALSE}
# library(devtools)
# install_github("ds-civic-data/gbfs")
```
```{r message=FALSE}
library(gbfs)
library(tidyverse)
library(ggmap)
```
```{r}
get_gbfs_cities() %>% filter(Location == "San Francisco Bay Area, CA")
get_gbfs(city = "https://gbfs.baywheels.com/gbfs/gbfs.json", feeds = "dynamic", directory = "pdx_gbfs")
get_gbfs(city = "https://gbfs.baywheels.com/gbfs/gbfs.json", feeds = "static", directory = "pdx_gbfs") # there is an error in this function.
list.files("pdx_gbfs")
```
```{r}
station_information <- readRDS("pdx_gbfs/station_information.rds")
head(station_information)
station_information %>% ggplot(aes(x=lon, y=lat, color=region_id)) + geom_point()
```
East Bay
```{r}
station_information <- readRDS("pdx_gbfs/station_information.rds")
head(station_information)
station_information %>% ggplot(aes(x=lon, y=lat)) +
geom_point() +
scale_colour_gradient(low = "orange", high = "blue")
```
Oakland
```{r}
head(station_information)
```
Near real time data
```{r}
station_status <- readRDS("pdx_gbfs/station_status.rds")
head(station_status)
#tail(station_status)
#dim(station_status)
#head(oakland.stations)
#dim(oakland.stations)
station_status %>% count(station_id)
station_information_02 <- station_information %>% left_join(station_status, by = "station_id" )
#head(oakland.status)
#tail(oakland.status)
#dim(oakland.status)
station_information_02 %>%
summarise(n=n(),mean=mean(num_bikes_available),min=min(num_bikes_available),max=max(num_bikes_available))
station_information_02 %>% group_by(name) %>%
summarise(n=n(),mean=mean(num_bikes_available),min=min(num_bikes_available),max=max(num_bikes_available))
```
```{r}
system_information <- readRDS("pdx_gbfs/system_information.rds")
system_information %>%
head()
```