Cyclistic Bike Share Capstone Project

Summary of Analysis for Cyclistic

It seems that weather plays a huge role as far as when both members and casual riders choose to ride their bikes. July being the busiest month for the bike share, and December being the lowest supports this information.

When it comes to specific days of the week, it seems that Tuesday and Thursday are the days where members are riding their bikes the most.

Members and casual riders tend to ride during 3PM-6PM. This makes sense suggesting that our member users would mostly be riding home to their place of work and our casual riders could be running errands or riding for leisure.

Members typically start or end their rides at Kingsbury and Kinzie St, while our casual riders tend to start at and at Streeter Dr and Grand Ave. I did not find any solid explanation as to why other than the possibility that they may live in the area.

When it comes to casual riders, the largest spike tends to happen over the weekends.

With both members and casual bike users, Saturdays are the busiest day.

Ultimately, the members ride more often than our casual riders.

Casual users ride for longer distances than our member rides, which to me indicates that our member users are likely riding to and from work, where the casual users are riding for exercise/leisure.

My Recommendations Based on My Analysis

From a consumer perspective, I think that an option for different lengths of membership subscriptions would be very valuable. Some consumers may be intimidated by the up front payment for a year subscription where an option for month to month, or even a 3 month subscription could be beneficial. Seeing how the ride count is at its highest during the summer months, specifically the 3 month membership suggestion would be a perfect way to efficiently increase membership and provide flexible pricing.

Increasing visibility of our marketing campaign at locations where casual users frequent the most could make the marketing efforts more effective.

Incentives could be an efficient way to encourage casual riders to pursue a membership. Emphasizing the benefits could persuade our casual riders to make the decision to secure their membership.

How do Cyclistic’s annual members and casual riders use their bikes differently?

The provided information is specific to annual members and casual riders of the Cyclistic Bike Share program. The data used for these findings is during the period from July of 2022 to June of 2023.

Here is My summary of Key Findings

  • Classic bikes are the most preferred bike type among both members and casual riders.
  • Kinzie St and Kingsbury are the top start and end positions for members and Streeter Dr and Grand Ave are preferred by our casual riders.
  • Both casual and member riders ride the most during 3PM-6PM.
  • Members prefer riding on weekdays, specifically on Tuesday and Thursday. Our casual riders prefer weekends, suggesting different reasons for usage for both groups.
  • Saturday is the most popular day of the week for riders in both groups. This was the only day of the week where casual riders surpassed the members in ride counts.
  • April to October seem to be the preferred period for both types of riders which is likely due to the favorable weather during these months.
  • July is the most popular month for both riders which is likely due to the peak of summer weather taking place at this time. These findings are important when considering what strategies and decisions are to be made to cater to both member and casual riders.

The data has been made available by Motivate International Inc. under this license

Shown below are my processes in analyzing the Cyclistic Bike Share data

Install/Library Packages

knitr::opts_chunk$set(echo = FALSE,message = FALSE,error = FALSE)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.4.4     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.1
## ✔ purrr     1.0.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(janitor)
## 
## Attaching package: 'janitor'
## 
## The following objects are masked from 'package:stats':
## 
##     chisq.test, fisher.test
library(lubridate)
library(scales)
## 
## Attaching package: 'scales'
## 
## The following object is masked from 'package:purrr':
## 
##     discard
## 
## The following object is masked from 'package:readr':
## 
##     col_factor
rm(list=ls())

Import the last 12 Months of Data

df1 <- read_csv("Updated Bikeshare/202207-divvy-tripdata.csv")
df2 <- read_csv("Updated Bikeshare/202208-divvy-tripdata.csv")
df3 <- read_csv("Updated Bikeshare/202209-divvy-tripdata.csv")
df4 <- read_csv("Updated Bikeshare/202210-divvy-tripdata.csv")
df5 <- read_csv("Updated Bikeshare/202211-divvy-tripdata.csv")
df6 <- read_csv("Updated Bikeshare/202212-divvy-tripdata.csv")
df7 <- read_csv("Updated Bikeshare/202301-divvy-tripdata.csv")
df8 <- read_csv("Updated Bikeshare/202302-divvy-tripdata.csv")
df9 <- read_csv("Updated Bikeshare/202303-divvy-tripdata.csv")
df10 <- read_csv("Updated Bikeshare/202304-divvy-tripdata.csv")
df11 <- read_csv("Updated Bikeshare/202305-divvy-tripdata.csv")
df12 <- read_csv("Updated Bikeshare/202306-divvy-tripdata.csv")

Combine 12 Dataframes into One Dataframe

bikes_rides <- rbind(df1,df2,df3,df4,df5,df6,df7,df8,df9,df10,df11,df12)

Clean the Data

bikes_rides <- janitor::remove_empty(bikes_rides,which = c("cols"))
bikes_rides <- janitor::remove_empty(bikes_rides,which = c("rows"))
bikes_rides <- bikes_rides %>% filter(start_station_name !="")

Convert the Data/Time to Date/Time

bikes_rides$Ymd <- as.Date(bikes_rides$started_at)
bikes_rides$started_at <- lubridate::ymd_hms(bikes_rides$started_at)
## Warning: 19 failed to parse.
bikes_rides$ended_at <- lubridate::ymd_hms(bikes_rides$ended_at)
## Warning: 20 failed to parse.
bikes_rides$start_hour <- lubridate::hour(bikes_rides$started_at)
bikes_rides$end_hour <- lubridate::hour(bikes_rides$ended_at)

Create New Columns for Duration of Each Bike Ride

bikes_rides$Hours <- difftime(bikes_rides$ended_at,bikes_rides$started_at,units = c("hours"))
bikes_rides$Minutes <- difftime(bikes_rides$ended_at,bikes_rides$started_at,units = c("mins"))
bikes_rides <- bikes_rides %>% filter(Minutes >0)

Inspect the Newly Created Table

summary(bikes_rides)
##    ride_id          rideable_type        started_at                    
##  Length:4921002     Length:4921002     Min.   :2022-07-01 00:00:01.00  
##  Class :character   Class :character   1st Qu.:2022-08-24 18:34:05.00  
##  Mode  :character   Mode  :character   Median :2022-11-01 17:17:51.50  
##                                        Mean   :2022-12-12 22:39:56.88  
##                                        3rd Qu.:2023-04-20 17:50:14.50  
##                                        Max.   :2023-06-30 23:59:45.00  
##                                                                        
##     ended_at                      start_station_name start_station_id  
##  Min.   :2022-07-01 00:06:23.00   Length:4921002     Length:4921002    
##  1st Qu.:2022-08-24 18:52:25.00   Class :character   Class :character  
##  Median :2022-11-01 17:31:58.50   Mode  :character   Mode  :character  
##  Mean   :2022-12-12 22:59:17.61                                        
##  3rd Qu.:2023-04-20 18:04:13.75                                        
##  Max.   :2023-07-10 20:26:44.00                                        
##                                                                        
##  end_station_name   end_station_id       start_lat       start_lng     
##  Length:4921002     Length:4921002     Min.   :41.65   Min.   :-87.84  
##  Class :character   Class :character   1st Qu.:41.88   1st Qu.:-87.66  
##  Mode  :character   Mode  :character   Median :41.90   Median :-87.64  
##                                        Mean   :41.90   Mean   :-87.65  
##                                        3rd Qu.:41.93   3rd Qu.:-87.63  
##                                        Max.   :42.06   Max.   :-87.53  
##                                                                        
##     end_lat         end_lng       member_casual           Ymd            
##  Min.   : 0.00   Min.   :-88.16   Length:4921002     Min.   :2022-07-01  
##  1st Qu.:41.88   1st Qu.:-87.66   Class :character   1st Qu.:2022-08-24  
##  Median :41.90   Median :-87.64   Mode  :character   Median :2022-11-01  
##  Mean   :41.90   Mean   :-87.65                      Mean   :2022-12-12  
##  3rd Qu.:41.93   3rd Qu.:-87.63                      3rd Qu.:2023-04-20  
##  Max.   :42.37   Max.   :  0.00                      Max.   :2023-06-30  
##  NA's   :5795    NA's   :5795                                            
##    start_hour       end_hour        Hours            Minutes        
##  Min.   : 0.00   Min.   : 0.00   Length:4921002    Length:4921002   
##  1st Qu.:11.00   1st Qu.:11.00   Class :difftime   Class :difftime  
##  Median :15.00   Median :15.00   Mode  :numeric    Mode  :numeric   
##  Mean   :14.14   Mean   :14.29                                      
##  3rd Qu.:18.00   3rd Qu.:18.00                                      
##  Max.   :23.00   Max.   :23.00                                      
## 
head(bikes_rides)
## # A tibble: 6 × 18
##   ride_id          rideable_type started_at          ended_at           
##   <chr>            <chr>         <dttm>              <dttm>             
## 1 954144C2F67B1932 classic_bike  2022-07-05 08:12:47 2022-07-05 08:24:32
## 2 292E027607D218B6 classic_bike  2022-07-26 12:53:38 2022-07-26 12:55:31
## 3 57765852588AD6E0 classic_bike  2022-07-03 13:58:49 2022-07-03 14:06:32
## 4 B5B6BE44314590E6 classic_bike  2022-07-31 17:44:21 2022-07-31 18:42:50
## 5 A4C331F2A00E79E0 classic_bike  2022-07-13 19:49:06 2022-07-13 20:15:24
## 6 579D73BE2ED880B3 electric_bike 2022-07-01 17:04:35 2022-07-01 17:13:18
## # ℹ 14 more variables: start_station_name <chr>, start_station_id <chr>,
## #   end_station_name <chr>, end_station_id <chr>, start_lat <dbl>,
## #   start_lng <dbl>, end_lat <dbl>, end_lng <dbl>, member_casual <chr>,
## #   Ymd <date>, start_hour <int>, end_hour <int>, Hours <drtn>, Minutes <drtn>
dim(bikes_rides)
## [1] 4921002      18
colnames(bikes_rides)
##  [1] "ride_id"            "rideable_type"      "started_at"        
##  [4] "ended_at"           "start_station_name" "start_station_id"  
##  [7] "end_station_name"   "end_station_id"     "start_lat"         
## [10] "start_lng"          "end_lat"            "end_lng"           
## [13] "member_casual"      "Ymd"                "start_hour"        
## [16] "end_hour"           "Hours"              "Minutes"
str(bikes_rides)
## tibble [4,921,002 × 18] (S3: tbl_df/tbl/data.frame)
##  $ ride_id           : chr [1:4921002] "954144C2F67B1932" "292E027607D218B6" "57765852588AD6E0" "B5B6BE44314590E6" ...
##  $ rideable_type     : chr [1:4921002] "classic_bike" "classic_bike" "classic_bike" "classic_bike" ...
##  $ started_at        : POSIXct[1:4921002], format: "2022-07-05 08:12:47" "2022-07-26 12:53:38" ...
##  $ ended_at          : POSIXct[1:4921002], format: "2022-07-05 08:24:32" "2022-07-26 12:55:31" ...
##  $ start_station_name: chr [1:4921002] "Ashland Ave & Blackhawk St" "Buckingham Fountain (Temp)" "Buckingham Fountain (Temp)" "Buckingham Fountain (Temp)" ...
##  $ start_station_id  : chr [1:4921002] "13224" "15541" "15541" "15541" ...
##  $ end_station_name  : chr [1:4921002] "Kingsbury St & Kinzie St" "Michigan Ave & 8th St" "Michigan Ave & 8th St" "Woodlawn Ave & 55th St" ...
##  $ end_station_id    : chr [1:4921002] "KA1503000043" "623" "623" "TA1307000164" ...
##  $ start_lat         : num [1:4921002] 41.9 41.9 41.9 41.9 41.9 ...
##  $ start_lng         : num [1:4921002] -87.7 -87.6 -87.6 -87.6 -87.6 ...
##  $ end_lat           : num [1:4921002] 41.9 41.9 41.9 41.8 41.9 ...
##  $ end_lng           : num [1:4921002] -87.6 -87.6 -87.6 -87.6 -87.7 ...
##  $ member_casual     : chr [1:4921002] "member" "casual" "casual" "casual" ...
##  $ Ymd               : Date[1:4921002], format: "2022-07-05" "2022-07-26" ...
##  $ start_hour        : int [1:4921002] 8 12 13 17 19 17 18 20 22 9 ...
##  $ end_hour          : int [1:4921002] 8 12 14 18 20 17 18 21 23 9 ...
##  $ Hours             : 'difftime' num [1:4921002] 0.195833333333333 0.0313888888888889 0.128611111111111 0.974722222222222 ...
##   ..- attr(*, "units")= chr "hours"
##  $ Minutes           : 'difftime' num [1:4921002] 11.75 1.88333333333333 7.71666666666667 58.4833333333333 ...
##   ..- attr(*, "units")= chr "mins"
nrow(bikes_rides)
## [1] 4921002

Create a summary data frame

bikesrides2 <- bikes_rides %>% 
  group_by(Weekly = floor_date(started_at, "week"), start_hour) %>%
  summarise(
    Minutes = sum(Minutes),
    Mean = mean(Minutes),
    Median = median(Minutes),
    Max = max(Minutes),
    Min = min(Minutes),
    Count = n(),
    .groups = "drop")

Inspect the Newly Created Table

summary(bikesrides2)
##      Weekly             start_hour      Minutes             Mean         
##  Min.   :2022-06-26   Min.   : 0.00   Length:1272       Length:1272      
##  1st Qu.:2022-09-25   1st Qu.: 5.75   Class :difftime   Class :difftime  
##  Median :2022-12-25   Median :11.50   Mode  :numeric    Mode  :numeric   
##  Mean   :2022-12-25   Mean   :11.50                                      
##  3rd Qu.:2023-03-26   3rd Qu.:17.25                                      
##  Max.   :2023-06-25   Max.   :23.00                                      
##     Median             Max               Min               Count      
##  Length:1272       Length:1272       Length:1272       Min.   :   52  
##  Class :difftime   Class :difftime   Class :difftime   1st Qu.: 1034  
##  Mode  :numeric    Mode  :numeric    Mode  :numeric    Median : 2792  
##                                                        Mean   : 3869  
##                                                        3rd Qu.: 5738  
##                                                        Max.   :16459
head(bikesrides2)
## # A tibble: 6 × 8
##   Weekly              start_hour Minutes       Mean     Median Max   Min   Count
##   <dttm>                   <int> <drtn>        <drtn>   <drtn> <drt> <drt> <int>
## 1 2022-06-26 00:00:00          0 21939.33 mins 21939.3… 21939… 2193… 2193…   806
## 2 2022-06-26 00:00:00          1 16119.88 mins 16119.8… 16119… 1611… 1611…   607
## 3 2022-06-26 00:00:00          2 10671.18 mins 10671.1… 10671… 1067… 1067…   309
## 4 2022-06-26 00:00:00          3  5728.75 mins  5728.7…  5728…  572…  572…   157
## 5 2022-06-26 00:00:00          4  2150.65 mins  2150.6…  2150…  215…  215…   134
## 6 2022-06-26 00:00:00          5  6901.10 mins  6901.1…  6901…  690…  690…   288
dim(bikesrides2)
## [1] 1272    8
colnames(bikesrides2)
## [1] "Weekly"     "start_hour" "Minutes"    "Mean"       "Median"    
## [6] "Max"        "Min"        "Count"
str(bikesrides2)
## tibble [1,272 × 8] (S3: tbl_df/tbl/data.frame)
##  $ Weekly    : POSIXct[1:1272], format: "2022-06-26" "2022-06-26" ...
##  $ start_hour: int [1:1272] 0 1 2 3 4 5 6 7 8 9 ...
##  $ Minutes   : 'difftime' num [1:1272] 21939.3333333333 16119.8833333333 10671.1833333333 5728.75 ...
##   ..- attr(*, "units")= chr "mins"
##  $ Mean      : 'difftime' num [1:1272] 21939.3333333333 16119.8833333333 10671.1833333333 5728.75 ...
##   ..- attr(*, "units")= chr "mins"
##  $ Median    : 'difftime' num [1:1272] 21939.3333333333 16119.8833333333 10671.1833333333 5728.75 ...
##   ..- attr(*, "units")= chr "mins"
##  $ Max       : 'difftime' num [1:1272] 21939.3333333333 16119.8833333333 10671.1833333333 5728.75 ...
##   ..- attr(*, "units")= chr "mins"
##  $ Min       : 'difftime' num [1:1272] 21939.3333333333 16119.8833333333 10671.1833333333 5728.75 ...
##   ..- attr(*, "units")= chr "mins"
##  $ Count     : int [1:1272] 806 607 309 157 134 288 717 1051 1537 1913 ...
nrow(bikesrides2)
## [1] 1272

Calculate the Moving Average

bikesrides2$CntMA <- forecast::ma(bikesrides2$Count,28)

Plot Rides by Date

Summary of Hourly Counts

summary(bikesrides2$Count)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##      52    1034    2792    3869    5738   16459

Hourly Counts Table

xtabs(bikesrides2$Count~bikesrides2$start_hour)
## bikesrides2$start_hour
##      0      1      2      3      4      5      6      7      8      9     10 
##  64550  40687  23862  13898  12246  38237 115225 207758 261167 197165 201692 
##     11     12     13     14     15     16     17     18     19     20     21 
## 245634 284739 288746 296755 348493 438899 509893 418022 301119 210347 169896 
##     22     23 
## 136588  95384

Add Monthly Column

bikesrides2$Monthly <- lubridate::month(bikesrides2$Weekly)

Rides Per Day Count Visualization

bikesrides2 %>% ggplot() + geom_col(aes(x=Weekly,y=Count)) +
  scale_y_continuous(labels = comma) +
  labs(title = "Rides Per Day Count",
       subtitle = "Based on 28 day moving average",
       y="Average rides per day")  

Rides per Hour Count Visualization

bikesrides2 %>% ggplot() + geom_col(aes(x=start_hour,y=Count)) +
  scale_y_continuous(labels = comma) +
  labs(title = "Rides per Hour Count",
       y="Rides per Hour") 

Analysis of Ride Time Minutes

Trip Minutes Weekly Average Visualization

ggplot(bikesrides2) + geom_col(aes(x=Weekly,y=Mean)) +
  labs(title="Trip Minutes Weekly Average", y ="Ride Time Average(min)") +
  scale_y_continuous(labels = comma)

Number of Rides by Rider Type Visualization

bikes_rides %>%
  mutate(weekday = wday(started_at, label = TRUE)) %>%
  group_by(member_casual, weekday) %>%
  summarise(
    number_of_rides = n(),
    average_duration = mean(Minutes)
  ) %>%
  arrange(member_casual, weekday) %>%
  ggplot(aes(x = weekday, y = number_of_rides, fill = member_casual)) +
  geom_col(position = position_dodge()) +
  scale_y_continuous(labels = scales::comma) +
  labs(
    title = "Total Rides By Weekday",
    x = "Weekday",
    y = "Number of Rides",
    fill = "Member Type"
  )

Average Duration By Weekday Visualization

bikes_rides %>%
  mutate(weekday = wday(started_at, label = TRUE)) %>%
  group_by(member_casual, weekday, .groups = "drop") %>%
  summarise(
    number_of_rides = n(),
    average_duration = mean(Minutes)
  ) %>%
  arrange(member_casual, weekday) %>%
  ggplot(aes(x = weekday, y = average_duration / 60, fill = member_casual)) +
  geom_col(position = position_dodge()) +
  scale_y_continuous(labels = scales::comma, name = "Average Duration (hours)") +
  labs(
    title = "Average Ride Duration by Weekday",
    x = "Weekday",
    fill = "Member Type"
  )

Rides by Bike Type Count

Summary of Bike Types
bikestype <- bikes_rides %>% 
  group_by(member_casual, rideable_type, Weekly = floor_date(started_at, "week")) %>%
  summarise(
    Minutes = sum(Minutes),
    Mean = mean(Minutes),
    Median = median(Minutes),
    Max = max(Minutes),
    Min = min(Minutes),
    Count = n(),
    .groups = "drop"
  )

Rides by Bike Type Visualization

ggplot(bikestype) + geom_area(aes(x=Weekly,y=Count,col=rideable_type)) +
  scale_y_continuous(labels = comma) +
  labs(title="Rides by Bike Type")

Rides by Rider Type Visualization

ggplot(bikestype) + geom_col(aes(x=Weekly,y=Count,fill=member_casual)) +
  scale_y_continuous(labels = comma) +
  labs(title="Rides by Rider Type")

Ride Minutes per Week Visualization

ggplot(bikestype) + geom_col(aes(x=Weekly,y=Minutes)) +
  scale_y_continuous(labels = comma) + facet_wrap(~rideable_type) +
  labs(title="Ride Minutes per week")

Ride Minutes By Type/Week visualization

ggplot(bikestype,aes(x=Weekly,y=Minutes,fill=rideable_type)) + 
  geom_area(stat = "identity", position = position_dodge(), alpha = 0.50) +
  scale_y_continuous(labels = comma) + 
  labs(title = "Rides Minutes by Bike Type/Week",
       y="Trip In Minutes")
## Warning: Width not defined
## ℹ Set with `position_dodge(width = ...)`

Top 5 Start Stations

bikes_rides %>% count(start_station_name, sort = TRUE) %>%
  top_n(10) %>% ggplot() + geom_col(aes(x=reorder(start_station_name,n),y=n)) +
  coord_flip() + labs(title = "Top 10 Start Stations",
                      y = "Ride Count",x="Station Name") +
  scale_y_continuous(labels = comma)

Top 5 Start Stations with Member and Casual Riders

bikes_rides %>%
  count(start_station_name, member_casual, sort = TRUE) %>%
  top_n(10) %>%
  ggplot() + 
  geom_col(aes(x = reorder(start_station_name, n), y = n, fill = member_casual)) +
  coord_flip() + 
  labs(title = "Top 10 Start Stations with Member and Casual Riders",
       y = "Count of Rides", x = "Station Name") +
  scale_y_continuous(labels = comma)