Business Question: How do annual members and casual riders use Cyclistic bikes differently?

Cyclistic is a bike-share company in Chicago.The director of marketing believes the company’s future success depends on maximizing the number of annual memberships. Customers who purchase single-ride or full-day passes are referred to as casual riders. Customers who purchase annual memberships are Cyclistic members.As a junior Data Analyst I have been assigned the task to find out how casual riders and annual members use Cyclistic bikes differently.

Data: Cyclistic’s historical trip data

The data used was Cyclistic’s historical trip data. I used a quarter of the 2020 (current year) data to analyze and identify trends to answer my research question. After downloading and saving .csv file data. I exported into Google sheets, identified how it was organised, used sort and filter functions to check for any anomalies in the data. I realized some ride lengths are negative and some end stations are missing. Based on my analysis, I made the assumption to remove all negative ride lengths because duration cannot be negative and ignored the missing end stations because they had appropriate ride lengths so its not a problem for the analysis. But This implies there was an omission error in the data collection. After further checking and confirming that data is void of every error that might affect my analysis. I created a new column to convert the numeric weekdays(1:sunday-7:saturday) to actual weekdays using the VLOOKUP function. The cleaned and organized data is now saved as .csv file, downloaded and exported to RStudio for further analysis and visualization. #In RStudio:

Setting up my environment

Notes: setting up my R environment by loading the ‘tidyverse’, ‘ggplot2’ and other needed packages for analyzing and visualizing the data.

library(tidyverse)
## Warning: package 'ggplot2' was built under R version 4.3.2
## Warning: package 'dplyr' was built under R version 4.3.2
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.3     ✔ readr     2.1.4
## ✔ forcats   1.0.0     ✔ stringr   1.5.0
## ✔ ggplot2   3.4.4     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.0
## ✔ 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(lubridate)
library(dplyr)
library(skimr)
## Warning: package 'skimr' was built under R version 4.3.2
library(ggplot2)

Loading and Viewing the Data (trip_data)

Notes: Loading and viewing my bike trips data set

trip_data<-read.csv("202004_divvy_tripdata.csv")
View(trip_data)

Getting to Know my Data

Notes: Exploring the bike trips data by previewing the summary and column names of the data to more about the data.

View(trip_data)
head(trip_data)
##            ride_id rideable_type weekday      started_at        ended_at
## 1 A847FADBBC638E45   docked_bike       1 4/26/2020 17:45 4/26/2020 18:12
## 2 5405B80E996FF60D   docked_bike       6 4/17/2020 17:08 4/17/2020 17:17
## 3 5DD24A79A4E006F4   docked_bike       4  4/1/2020 17:54  4/1/2020 18:08
## 4 2A59BBDF5CDBA725   docked_bike       3  4/7/2020 12:50  4/7/2020 13:02
## 5 27AD306C119C6158   docked_bike       7 4/18/2020 10:22 4/18/2020 11:15
## 6 356216E875132F61   docked_bike       5 4/30/2020 17:55 4/30/2020 18:01
##   ride_length                  start_station_name start_station_id
## 1     0:26:49                        Eckhart Park               86
## 2     0:08:09           Drake Ave & Fullerton Ave              503
## 3     0:14:23                McClurg Ct & Erie St              142
## 4     0:12:12        California Ave & Division St              216
## 5     0:52:55                Rush St & Hubbard St              125
## 6     0:05:24 Mies van der Rohe Way & Chicago Ave              173
##              end_station_name end_station_id start_lat start_lng end_lat
## 1 Lincoln Ave & Diversey Pkwy            152   41.8964  -87.6610 41.9322
## 2             Kosciuszko Park            499   41.9244  -87.7154 41.9306
## 3  Indiana Ave & Roosevelt Rd            255   41.8945  -87.6179 41.8679
## 4      Wood St & Augusta Blvd            657   41.9030  -87.6975 41.8992
## 5  Sheridan Rd & Lawrence Ave            323   41.8902  -87.6262 41.9695
## 6     Streeter Dr & Grand Ave             35   41.8969  -87.6217 41.8923
##    end_lng member_casual day_num      days weekday.1  trip_day
## 1 -87.6586        member       1    Sunday         1    Sunday
## 2 -87.7238        member       2    Monday         6    Friday
## 3 -87.6230        member       3   Tuesday         4 Wednesday
## 4 -87.6722        member       4 Wednesday         3   Tuesday
## 5 -87.6547        casual       5  Thursday         7  Saturday
## 6 -87.6120        member       6    Friday         5  Thursday
colnames(trip_data)
##  [1] "ride_id"            "rideable_type"      "weekday"           
##  [4] "started_at"         "ended_at"           "ride_length"       
##  [7] "start_station_name" "start_station_id"   "end_station_name"  
## [10] "end_station_id"     "start_lat"          "start_lng"         
## [13] "end_lat"            "end_lng"            "member_casual"     
## [16] "day_num"            "days"               "weekday.1"         
## [19] "trip_day"
str(trip_data)
## 'data.frame':    84717 obs. of  19 variables:
##  $ ride_id           : chr  "A847FADBBC638E45" "5405B80E996FF60D" "5DD24A79A4E006F4" "2A59BBDF5CDBA725" ...
##  $ rideable_type     : chr  "docked_bike" "docked_bike" "docked_bike" "docked_bike" ...
##  $ weekday           : int  1 6 4 3 7 5 5 3 4 7 ...
##  $ started_at        : chr  "4/26/2020 17:45" "4/17/2020 17:08" "4/1/2020 17:54" "4/7/2020 12:50" ...
##  $ ended_at          : chr  "4/26/2020 18:12" "4/17/2020 17:17" "4/1/2020 18:08" "4/7/2020 13:02" ...
##  $ ride_length       : chr  "0:26:49" "0:08:09" "0:14:23" "0:12:12" ...
##  $ start_station_name: chr  "Eckhart Park" "Drake Ave & Fullerton Ave" "McClurg Ct & Erie St" "California Ave & Division St" ...
##  $ start_station_id  : int  86 503 142 216 125 173 35 434 627 377 ...
##  $ end_station_name  : chr  "Lincoln Ave & Diversey Pkwy" "Kosciuszko Park" "Indiana Ave & Roosevelt Rd" "Wood St & Augusta Blvd" ...
##  $ end_station_id    : int  152 499 255 657 323 35 635 382 359 508 ...
##  $ start_lat         : num  41.9 41.9 41.9 41.9 41.9 ...
##  $ start_lng         : num  -87.7 -87.7 -87.6 -87.7 -87.6 ...
##  $ end_lat           : num  41.9 41.9 41.9 41.9 42 ...
##  $ end_lng           : num  -87.7 -87.7 -87.6 -87.7 -87.7 ...
##  $ member_casual     : chr  "member" "member" "member" "member" ...
##  $ day_num           : int  1 2 3 4 5 6 7 NA NA NA ...
##  $ days              : chr  "Sunday" "Monday" "Tuesday" "Wednesday" ...
##  $ weekday.1         : int  1 6 4 3 7 5 5 3 4 7 ...
##  $ trip_day          : chr  "Sunday" "Friday" "Wednesday" "Tuesday" ...

Converting the Ride Lengths from Date Form to Hours

Notes: Converting the ride_length in date form to numeric form(in hours) by adding the new_ride_length column.

trip_data_1 <- trip_data %>%
  separate(col = ride_length, into = c("H", "M", "S"), sep = "\\:", remove = FALSE)%>%
  #separate(col = S, into = c("S", "Z"), sep = "\\+", remove = TRUE) %>% 
  mutate(H = as.numeric(H)) %>% 
  mutate(M = as.numeric(M)/60) %>% 
  mutate(S = as.numeric(S)/60/60) %>% 
  mutate(ride_length_new = H+M+S)

Viewing the New Data (trip_data_1)

Notes:Viewing the new data trip_data_1 after adding the new column, new_ride_length

View(trip_data_1)
head(trip_data_1)
##            ride_id rideable_type weekday      started_at        ended_at
## 1 A847FADBBC638E45   docked_bike       1 4/26/2020 17:45 4/26/2020 18:12
## 2 5405B80E996FF60D   docked_bike       6 4/17/2020 17:08 4/17/2020 17:17
## 3 5DD24A79A4E006F4   docked_bike       4  4/1/2020 17:54  4/1/2020 18:08
## 4 2A59BBDF5CDBA725   docked_bike       3  4/7/2020 12:50  4/7/2020 13:02
## 5 27AD306C119C6158   docked_bike       7 4/18/2020 10:22 4/18/2020 11:15
## 6 356216E875132F61   docked_bike       5 4/30/2020 17:55 4/30/2020 18:01
##   ride_length H          M           S                  start_station_name
## 1     0:26:49 0 0.43333333 0.013611111                        Eckhart Park
## 2     0:08:09 0 0.13333333 0.002500000           Drake Ave & Fullerton Ave
## 3     0:14:23 0 0.23333333 0.006388889                McClurg Ct & Erie St
## 4     0:12:12 0 0.20000000 0.003333333        California Ave & Division St
## 5     0:52:55 0 0.86666667 0.015277778                Rush St & Hubbard St
## 6     0:05:24 0 0.08333333 0.006666667 Mies van der Rohe Way & Chicago Ave
##   start_station_id            end_station_name end_station_id start_lat
## 1               86 Lincoln Ave & Diversey Pkwy            152   41.8964
## 2              503             Kosciuszko Park            499   41.9244
## 3              142  Indiana Ave & Roosevelt Rd            255   41.8945
## 4              216      Wood St & Augusta Blvd            657   41.9030
## 5              125  Sheridan Rd & Lawrence Ave            323   41.8902
## 6              173     Streeter Dr & Grand Ave             35   41.8969
##   start_lng end_lat  end_lng member_casual day_num      days weekday.1
## 1  -87.6610 41.9322 -87.6586        member       1    Sunday         1
## 2  -87.7154 41.9306 -87.7238        member       2    Monday         6
## 3  -87.6179 41.8679 -87.6230        member       3   Tuesday         4
## 4  -87.6975 41.8992 -87.6722        member       4 Wednesday         3
## 5  -87.6262 41.9695 -87.6547        casual       5  Thursday         7
## 6  -87.6217 41.8923 -87.6120        member       6    Friday         5
##    trip_day ride_length_new
## 1    Sunday       0.4469444
## 2    Friday       0.1358333
## 3 Wednesday       0.2397222
## 4   Tuesday       0.2033333
## 5  Saturday       0.8819444
## 6  Thursday       0.0900000
colnames(trip_data_1)
##  [1] "ride_id"            "rideable_type"      "weekday"           
##  [4] "started_at"         "ended_at"           "ride_length"       
##  [7] "H"                  "M"                  "S"                 
## [10] "start_station_name" "start_station_id"   "end_station_name"  
## [13] "end_station_id"     "start_lat"          "start_lng"         
## [16] "end_lat"            "end_lng"            "member_casual"     
## [19] "day_num"            "days"               "weekday.1"         
## [22] "trip_day"           "ride_length_new"

Calculating the Mean, Max. and Min. Ride Lengths

Notes: Using the summarize function to summarize the data into mean ride length, maximum and minimum ride lengths

trip_data_summary<-
  trip_data_1 %>% 
  summarise(mean_ride_length=mean(ride_length_new),
            max_ride_length=max(ride_length_new),
            min_ride_length=min(ride_length_new))
trip_data_summary
##   mean_ride_length max_ride_length min_ride_length
## 1        0.5979195        978.6672    0.0002777778

The Mean and Max of Ride_Lengths according to Casual and Members Bikers

Notes: Calculating the mean and max. ride lengths of casual and member bikers separately.

trip_data_member<-
  filter(trip_data_1, trip_data_1$member_casual=="member")
mean_ride_length_member<-mean(trip_data_member$ride_length_new)
max_ride_length_member<-max(trip_data_member$ride_length_new)
trip_data_casual<-
  filter(trip_data_1, trip_data_1$member_casual=="casual") 
mean_ride_length_casual<-mean(trip_data_casual$ride_length_new)
max_ride_length_casual<-max(trip_data_casual$ride_length_new)
 
category<-c("mean_ride_length_casual","mean_ride_length_member","max_ride_length_casual","max_ride_length_member")
value<-c(mean_ride_length_casual,mean_ride_length_member,max_ride_length_casual,max_ride_length_member)
trip_data_summary_member_casual<-data.frame(category,value)
trip_data_summary_member_casual
##                  category       value
## 1 mean_ride_length_casual   1.2190426
## 2 mean_ride_length_member   0.3580057
## 3  max_ride_length_casual 928.0647222
## 4  max_ride_length_member 978.6672222

Visualization of the Data

Plotting trip_data_1 data using geom_point and geom_bar functions to visualize the data using the ggplot

Notes: Bar chart of Casual biker and Annual members. This Viz shows that as at 2020 the annual memberships are more than casual bikers.

ggplot(data = trip_data_1)+
  geom_bar(mapping = aes(x=member_casual, fill=member_casual))+
  #facet_wrap(~trip_day)+
  theme(axis.text.x = element_text(angle = 45, hjust = 1))

Notes: Bar chart of Casual and annual member according to trip days. The trend in this chart shows the similarity in how both Casual and Annual members use Cyclistic bikes in a week with more riders on weekends especially on Sundays.

ggplot(data = trip_data_1)+
  geom_bar(mapping = aes(x=trip_day, fill=trip_day))+
  facet_wrap(~member_casual)+
  theme(axis.text.x = element_text(angle = 45, hjust = 1))

Notes: A plot of Casual and Annual members against Ride lengths according to the trip days. The trend from this plot shows how Casual bikers use cyclistic different from Annual members. The Casual bikers averagely have high ride lengths than Annual members in a week.

ggplot(data = trip_data_1)+
  geom_point(mapping = aes(x=trip_day, y=ride_length_new, color=trip_day))+
  facet_wrap(~member_casual)+
  theme(axis.text.x = element_text(angle = 45, hjust = 1))

Notes: Detailed version of the above scatter plot. This shows in detail that Casual riders have high ride lengths on Weekdays while Annual members only ride for long duration on Weekends.

ggplot(data = trip_data_1)+
  geom_point(mapping = aes(x=member_casual, y=ride_length_new, color=member_casual))+
  facet_wrap(~trip_day)+
  theme(axis.text.x = element_text(angle = 45, hjust = 1))

Conclusion and Recommendation

Upon conducting an analysis and visualization of Cyclistic’s trip data for the quarter of 2020, I observed that Casual riders tend to utilize the bikes for longer durations on weekdays, resulting in higher average ride lengths throughout the week. Conversely, Annual members exhibit shorter ride durations compared to Casual riders, but demonstrate a preference for longer rides on weekends as opposed to weekdays. Given the observation that Casual riders tend to use the bikes for longer durations on weekdays, it would be beneficial to educate them on the benefits of becoming Annual members, as they demonstrate a preference for longer rides on weekdays. This could potentially lead to increased membership and a more balanced distribution of ride lengths throughout the week.