<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/blue-bikes-sharing-in-boston/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="https://datascienceplus.com/blue-bikes-sharing-in-boston/"> R Programming – DataScience+</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>Blue Bikes is a bicycle sharing system in the Boston, Massachusetts. The bikes sharing program started on 28 July 2011. This program aimed for individuals to use it for short-term basis for a price. The program allows individuals to borrow a bike from a dock station and retrun to another dock station after using it. According to 2017 <a rel="nofollow" href="https://www.bostonglobe.com/business/2017/05/25/hubway-set-for-big-expansion-and-year-round-service/TIfhZ7eZmzU3OE4cDayNzL/story.html" target="_blank">report</a>, there are more than 1600 bicycles in used. </p>
<p>The aims of the current project are to gain insight of the user who used this program such as gender. It also aimed to investigate the duration of the usage. The dataset used in this project can be found in this <a rel="nofollow" href="https://www.bluebikes.com/system-data" target="_blank">link</a>. For the purpose of this project, two datasets are used the station dataset as recorded in 16th August 2017 and the trip data on 8th August 2018.</p>
<pre><code>library(data.table) # for faster loading on large dataset
library(tidyverse) # load ggplot, dplyr
library(leaflet) # interactive mapping 
library(leaflet.extras) #extra mapping for leaflet
library(geosphere) #used to calculate distance
library(lubridate) #formatting date and time
library(gridExtra) # multiple plot arrange
library(grid) #multiple plot arrange
library(psych) #to get describe function

#load the data set
data &lt;- as.data.frame(fread(&quot;201807-bluebikes-tripdata.csv&quot;))
#load station data
station &lt;- read.csv(&quot;Hubway_Stations_as_of_July_2017.csv&quot;)
</code></pre>
<p>Before the analysis, let's visualize all the dock stations around Boston. </p>
<pre><code>map1 &lt;- station %>% 
  leaflet() %>%
  setView(lng = -71.0589, lat = 42.3601, zoom = 13) %>% 
  addTiles() %>%
  addMarkers(lng = station$Longitude, lat = station$Latitude, popup = station$Station)
map1
</code></pre>
<p><a rel="nofollow" href="https://i0.wp.com/datascienceplus.com/wp-content/uploads/2018/09/unnamed-chunk-2-1.png?ssl=1" target="_blank"><img sizes="(max-width: 490px) 100vw, 490px" src="https://i1.wp.com/datascienceplus.com/wp-content/uploads/2018/09/unnamed-chunk-2-1-490x490.png?w=450&ssl=1" alt="" class="wp-image-16665" data-recalc-dims="1"></a></p>
<p>As you can see above, these are the distribution of dock station around Boston. You can run the code in RStudio and interact with the map.</p>
<h3>Data Cleaning</h3>
<pre><code>glimpse(data)</code>
<em>## Observations: 242,891
## Variables: 15
## $ tripduration </em></pre>