This case study presents a capstone project focused on Cyclistic, a bike-share company. The primary objective is to analyze the usage patterns of bike users (both casual and members) to derive insights for strategizing the company’s upcoming marketing campaign
This is an analysis examining the distinctive usage patterns between casual users and members of Cyclistic, a bike-share company. Cyclistic operates with approximately 5,824 geotracked bicycles across a network of 692 stations throughout Chicago. These bikes are accessible from one station and can be returned to any other station within the system at any given time.This analysis is based on the Divvy case study “‘Sophisticated, Clear, and Polished’ of Oct 2020 to September 2021: Divvy and Data Visualization” written by Kevin Hartman (found here:https://artscience.blog/home/divvy-dataviz-case-study).
I’m utilizing datasets with altered names since Cyclistic is a fictitious company. These datasets, tailored for this case study, are suitable for addressing the business queries effectively. The data has been provided by Motivate International Inc. under a specific license.
My objective is to discern the distinctive usage patterns between annual members and casual riders of Cyclistic bikes. This analysis will aid in crafting marketing strategies focused on converting casual riders into annual members.
Cyclistic: A bike-share program that features more than 5,800 bicycles and 600 docking stations. Cyclistic sets itself apart by also offering reclining bikes, hand tricycles, and cargo bikes, making bike-share more inclusive to people with disabilities and riders who can’t use a standard two-wheeled bike. The majority of riders opt for traditional bikes; about 8% of riders use the assistive options. Cyclistic users are more likely to ride for leisure, but about 30% use them to commute to work each day.
Lily Moreno: The director of marketing and your manager. Moreno is responsible for the development of campaigns and initiatives to promote the bike-share program. These may include email,social media,and other channels. Cyclistic marketing analytics team: A team of data analysts who are responsible for collecting, analyzing,and reporting data that helps guide Cyclistic marketing strategy. You joined this team six months ago and have been busy learning about Cyclistic’s mission and business goals — as well as how you, as a junior data analyst, can help Cyclistic achieve them.
Cyclistic executive team: The notoriously detail-oriented executive team will decide whether to approve the recommended marketing program.
I have a couple of options here - but i will need to load the essential packages needed
library(tidyverse) #helps wrangle data library(lubridate) #helps wrangle date attributes library(ggplot2) #helps visualize data library(skimr) #For summerizing data library(janitor) #For cleaning data library(readr) #to provide a fast and friendly way to read rectangular data library(scales) #to get percent() function library(ggthemes) #complete themes which control all non-data display library(data.table) #aggregation of large datasets library(dplyr) #for data manipulation library(stringr) #provide string handling capabilities library(DT) #to return the probability density analysis library(tidyr) #creating tidy data library(corrplot) #to plot the graph of the correlation matrix library(leaflet) #to create interactive map
getwd()
setwd(“/Users/miftaaudeenjamiu/Desktop/divy_data”)
q2_2019 <- read_csv (“Divvy_Trips_2019_Q2.csv”) q3_2019 <- read_csv (“Divvy_Trips_2019_Q3.csv”) q4_2019 <- read_csv (“Divvy_Trips_2019_Q4.csv”) q1_2020 <- read_csv (“Divvy_Trips_2020_Q1.csv”)
colnames(q3_2019) colnames(q4_2019) colnames(q2_2019) colnames(q1_2020)
(q4_2019 <- rename(q4_2019 ,ride_id = trip_id ,rideable_type =
bikeid ,started_at = start_time
,ended_at = end_time
,start_station_name = from_station_name ,start_station_id =
from_station_id ,end_station_name = to_station_name ,end_station_id =
to_station_id ,member_casual = usertype))
(q3_2019 <- rename(q3_2019 ,ride_id = trip_id ,rideable_type =
bikeid ,started_at = start_time
,ended_at = end_time
,start_station_name = from_station_name ,start_station_id =
from_station_id ,end_station_name = to_station_name ,end_station_id =
to_station_id ,member_casual = usertype))
(q2_2019 <- rename(q2_2019 ,ride_id = “01 - Rental Details Rental
ID” ,rideable_type = “01 - Rental Details Bike ID” ,started_at = “01 -
Rental Details Local Start Time”
,ended_at = “01 - Rental Details Local End Time”
,start_station_name = “03 - Rental Start Station Name” ,start_station_id
= “03 - Rental Start Station ID” ,end_station_name = “02 - Rental End
Station Name” ,end_station_id = “02 - Rental End Station ID”
,member_casual = “User Type”))
str(q1_2020) str(q4_2019) str(q3_2019) str(q2_2019)
q4_2019 <- mutate(q4_2019, ride_id = as.character(ride_id) ,rideable_type = as.character(rideable_type)) q3_2019 <- mutate(q3_2019, ride_id = as.character(ride_id) ,rideable_type = as.character(rideable_type)) q2_2019 <- mutate(q2_2019, ride_id = as.character(ride_id) ,rideable_type = as.character(rideable_type))
str(q1_2020) str(q4_2019) str(q3_2019) str(q2_2019)
all_trip <- bind_rows(q2_2019, q3_2019, q4_2019, q1_2020)
all_trip <- all_trip %>%
select(-c(start_lat, start_lng, end_lat, end_lng, birthyear, gender, “01
- Rental Details Duration In Seconds Uncapped”, “05 - Member Details
Member Birthday Year”, “Member Gender”, “tripduration”))
head(all_trip) glimpse(all_trip)
colnames(all_trip) #List of column names nrow(all_trip) #How many rows are in data frame? dim(all_trip) #Dimensions of the data frame? head(all_trip) #See the first 6 rows of data frame. Also tail(all_trips) str(all_trip) #See list of columns and data types (numeric, character, etc) summary(all_trip) #Statistical summary of data. Mainly for numerics
table(all_trip$member_casual)
all_trip <- all_trip %>% mutate(member_casual = recode(member_casual ,“Subscriber” = “member” ,“Customer” = “casual”))
table(all_trip$member_casual)
all_trip\(date <- as.Date(all_trip\)started_at) #The default format is yyyy-mm-dd
all_trip\(month <- format(as.Date(all_trip\)date), “%m”)
all_trip\(day <- format(as.Date(all_trip\)date), “%d”)
all_trip\(year <- format(as.Date(all_trip\)date), “%Y”)
all_trip\(day_of_week <- format(as.Date(all_trip\)date), “%A”)
all_trip\(ended_at <- as.POSIXct(all_trip\)ended_at, format = “%Y-%m-%d %H:%M:%S”)
all_trip\(started_at <- as.POSIXct(all_trip\)started_at, format = “%Y-%m-%d %H:%M:%S”)
all_trip\(ride_length <- difftime(all_trip\)ended_at,all_trip$started_at)
str(all_trip)
is.factor(all_trip$ride_length)
all_trip\(ride_length <- as.numeric(as.character(all_trip\)ride_length))
is.numeric(all_trip$ride_length)
all_trips_v2 <- all_trip[!(all_trip\(start_station_name == "HQ QR" | all_trip\)ride_length<0),]
If we don’t handle our NA values we’re going to be in
for a bad time.
all_trips_v2 <- all_trips_v2 %>% filter(ride_length != “NA”,)
head(all_trips_v2)
mean(all_trips_v2$ride_length) #straight average (total ride length / rides)
median(all_trips_v2$ride_length) #midpoint number in the ascending array of ride lengths
max(all_trips_v2$ride_length) #longest ride
min(all_trips_v2$ride_length) #shortest ride
aggregate(all_trips_v2\(ride_length ~ all_trips_v2\)member_casual + all_trips_v2$day_of_week, FUN = mean)
all_trips_v2\(day_of_week <- ordered(all_trips_v2\)day_of_week, levels=c(“Sunday”, “Monday”, “Tuesday”, “Wednesday”, “Thursday”, “Friday”, “Saturday”))
aggregate(all_trips_v2\(ride_length ~ all_trips_v2\)member_casual + all_trips_v2$day_of_week, FUN = mean)
all_trips_v2 <- all_trips_v2 %>% mutate(weekday =format(as.Date(started_at), “%A”))
cleaned_data <- all_trips_v2 %>% group_by ( member_casual, weekday) %>% summarise(Average_duration = mean(ride_length), Number_of_rides = n()) %>% arrange(member_casual,weekday)
head(cleaned_data)
ggplot(data = cleaned_data, aes(x = weekday, y = Average_duration, fill = member_casual)) + geom_col(position = “dodge”) + scale_y_continuous() + labs(title = ‘Weekday vs Average Duration by UserType’, x = ‘Weekday’, y = ‘Average Duration’) + theme_minimal() + theme(axis.text.x = element_text(angle = 90))
ggplot(data = cleaned_data, aes(x = weekday, y = Number_of_rides,
fill = Average_duration)) + geom_col(position = “dodge”) +
labs(title = ‘Number_of_rides vs Weekday’, x = ‘Weekday’, y =
‘Number_of_rides’) + scale_y_continuous() + theme_minimal() +
theme(axis.text.x = element_text(angle = 90))
ranked_days <- all_trip %>%group_by(day_of_week,member_casual) %>% summarise(Number_of_rides = n(), Percentage_from_total_rides = percent(n()/nrow(all_trip)), .groups = ‘drop’)%>% arrange(desc(Number_of_rides))
ggplot(data = ranked_days,aes(x = reorder(day_of_week,-Number_of_rides),y = Number_of_rides,fill = day_of_week)) + geom_col(position = ‘dodge’) +scale_y_continuous(labels = scales::comma) + labs(title = ‘Day of the week vs Number of rides’, x = ‘Day of the week’, y = “Number of Rides”) + theme_minimal() + theme(axis.text.x = element_text(angle = 90))
all_trip <- all_trip %>% mutate(Month =format(as.Date(started_at), “%B”))
ranked_months <- all_trip %>%group_by(Month) %>% summarise(Number_of_rides = n(), Percentage_from_total_rides = percent(n()/nrow(all_trip)))%>% arrange(-Number_of_rides)
ggplot(data = ranked_months,aes(x = fct_relevel(Month,“January”,“February”,“March”, #Reorder by chronological order “April”,“May”,“June”,“July”,“August”, “September”, “October”,“November”,“December”),y = Number_of_rides,fill = Month)) + geom_col (position = “dodge”) +scale_y_continuous(labels = scales::comma) + labs(title = ‘Months of the year vs Number of rides’, x = ‘Months of the Year’, y = “Number of Rides”) + theme_minimal() + theme(axis.text.x = element_text(angle = 90))
The Avereage duration varies significantly between casual and member riders. Notably, casual riders tend to prolong their bike usage, indicating that members might primarily use the bikes for commuting, whereas casual riders lean towards recreational activities.
It is observed that the average duration of bike usage is not solely determined by the number of rides. This is evident in the fact that casual riders spend more time using the bikes compared to member riders, even though they may not have a higher ride count.
Examining the ride frequency based on the busiest day of the week highlights a decrease in bike usage during the weekend. This observation further indicates that weekdays see more commuting trips, while recreational use is more prevalent during the weekend.
Illustrating the frequency of rides across different months reveals a binomial distribution pattern, particularly concentrated around the summer months. This suggests that there is a notable increase in ride activity during the summer season compared to other months.
Privacy concerns prevent the utilization of personally identifiable information from riders. Consequently, I couldn’t establish connections between pass purchases and credit card numbers to ascertain whether casual riders reside in the Cyclistic service area or have made multiple single pass purchases.
Incorporating demographic information of members, including details like income, age, and gender, will aid in identifying effective channels for marketing campaigns and shaping pricing strategies. For instance, digital media may be utilized to target younger generations, while print media might be more suitable for reaching older demographics.