Cyclistic is an imaginary bike-share offering company that operates in Chicago,the company has over 5824 bikes with over 692 stations accross chicago. I would be analyzing a dataset from Motivate International Inc. assuming to be the data analyst for the marketing team in cyclistic.
Cyclistic has two types of customers: annual members and casual riders. The director of marketing wants find a strategy to convert casual riders to annual members. Thats why Moreno has asked the marketing team to analyze the historical bike trip data of Cyclistic to identify trends on how to convert casual riders to annual ones and to know the suitable digital media for advertisement.
tinytex::install_tinytex() #to export to pdf
library(tidyverse)
library(ggplot2)
library(lubridate)
library(dplyr)
library(readr)
library(janitor)
library(data.table)
library(tidyr)
library(hms)
library(rmarkdown)
12 months of Cyclistic’s historical trip data was downloaded in separate .csv files, from april 2022 to march 2023. The data we will be analyzing is a first-party type — data collected and used by Cyclistic. For the purposes of this capstone project, the data was provided under a license from divvybikes.com, a real bike-share company in Chicago. Riders’ personal information has been scrubbed.
april_22 <- read_csv("C:/Users/HP PC/Documents/cyclistic_trip_data/202204-divvy-tripdata.csv")
may_22 <- read_csv("C:/Users/HP PC/Documents/cyclistic_trip_data/202205-divvy-tripdata.csv")
june_22 <- read_csv("C:/Users/HP PC/Documents/cyclistic_trip_data/202206-divvy-tripdata.csv")
july_22 <- read_csv("C:/Users/HP PC/Documents/cyclistic_trip_data/202207-divvy-tripdata.csv")
aug_22 <- read_csv("C:/Users/HP PC/Documents/cyclistic_trip_data/202208-divvy-tripdata.csv")
sep_22 <- read_csv("C:/Users/HP PC/Documents/cyclistic_trip_data/202209-divvy-publictripdata.csv")
oct_22 <- read_csv("C:/Users/HP PC/Documents/cyclistic_trip_data/202210-divvy-tripdata.csv")
nov_22 <- read_csv("C:/Users/HP PC/Documents/cyclistic_trip_data/202211-divvy-tripdata.csv")
dec_22 <- read_csv("C:/Users/HP PC/Documents/cyclistic_trip_data/202212-divvy-tripdata.csv")
jan_23 <- read_csv("C:/Users/HP PC/Documents/cyclistic_trip_data/202301-divvy-tripdata.csv")
feb_23 <- read_csv("C:/Users/HP PC/Documents/cyclistic_trip_data/202302-divvy-tripdata.csv")
march_23 <- read_csv("C:/Users/HP PC/Documents/cyclistic_trip_data/202303-divvy-tripdata.csv")
when Checking the data for completeness i saw that the “start station name and ID” and “end station name and ID” for some rides were missing.
due to data privacy issues, riders personal information were not identified, although each ride ID was checked and confirmed to be distinct, there is no way to confirm if the same rider has purchased multiple single passes, or if they live in the Cyclistic service area.
Combining individual month datasets into one data frame
all_months <- rbind(april_22, may_22, june_22, july_22, aug_22, sep_22, oct_22, nov_22, dec_22, jan_23, feb_23, march_23)
Narrowing down the data, focusing on only interested columns
trimmed_all_months <- select(all_months, "rideable_type", "started_at", "ended_at", "member_casual")
Creating a new data frame to contain new columns
new_all_months <- trimmed_all_months
Create ride_length column
new_all_months$ride_length <- difftime(new_all_months$ended_at, new_all_months$started_at, units = "mins")
new_all_months$ride_length <- round(new_all_months$ride_length, digits = 1)
Creating columns for all date calculations
new_all_months$date <- as.Date(new_all_months$started_at)
new_all_months$day_of_week <- weekdays(new_all_months$started_at) #day of week calculation
new_all_months$day_of_week <- format(as.Date(new_all_months$date),"%A") #day of week column
new_all_months$month <- format(as.Date(new_all_months$date), "%m") #month column
new_all_months$day <- format(as.Date(new_all_months$date), "%d") #day column
new_all_months$year <- format(as.Date(new_all_months$date), "%Y") #year column
new_all_months$time <- format(as.Date(new_all_months$date), "%H:%M:%S") #time formatted HH:MM:SS
new_all_months$time <- as_hms(new_all_months$started_at) #time column
new_all_months$hour <- hour(new_all_months$time) #create new column for hour
Removing where the column ‘ride_length’ is 0 or negative alongside with duplicate and N/A rows
new_all_months <- na.omit(new_all_months) #remove rows with NA
new_all_months <- distinct(new_all_months) #remove duplicate rows
new_all_months <- new_all_months[!(new_all_months$ride_length <=0),]
View(new_all_months)
new_all_months %>%
group_by(member_casual)%>%
summarize(number_of_rides = n())%>%
arrange(member_casual)%>%
ggplot(aes(x = member_casual, y = number_of_rides, fill = member_casual)) +
labs(title = "Total Trips By Customer Type") +
geom_col(width = 0.5, position = position_dodge(width = 0.5)) +
scale_y_continuous(labels = function(x) format(x, scientific = FALSE))
This confirms that truely the annual members are much more profitable than the casual risers, as the total rides for annual members are more then that of the casual riders.
new_all_months %>%
group_by(member_casual)%>%
summarize(average_ride_length = mean(ride_length))%>%
ggplot(aes(x = member_casual, y = average_ride_length, fill = member_casual)) +
labs(title = "Average Ride Length") +
geom_col(width = 0.5, position = position_dodge(width = 0.5))
Here the average ride length for casual members is higher than that of annual members, which tells us that the casual riders have longer ride sessions mainly because the use the service for leisure
new_all_months %>%
group_by(member_casual, hour)%>%
summarize(number_of_trips = n())%>%
ggplot(aes(x = hour, y = number_of_trips, color = member_casual, group = member_casual)) +
geom_line() +
labs(title = "Active Bike rides by Hour", x = "Time of Day") +
theme(axis.text.x = element_text(angle = 90)) +
scale_y_continuous(labels = function(x) format(x, scientific = FALSE))
From the graph we see that the annual members have bike trips in the morning and evening hours, which tells us the annual members use the service to commute while. while the casual riders have bike trips in the evening hours which confirms our previous assumption that they mainly use the service for leisure.
new_all_months %>%
group_by(member_casual, day_of_week)%>%
summarize(number_of_rides = n())%>%
arrange(member_casual, day_of_week)%>%
ggplot(aes(x = day_of_week, y = number_of_rides, fill = member_casual)) +
labs(title = "Total Rides per Weekday") +
geom_col(width = 0.5, position = position_dodge(width = 0.5)) +
scale_y_continuous(labels = function(x) format(x, scientific = FALSE))
From the chat we see that the annual members are consistent in taking bike trips through out the week, where as casual members mainly take trips during the weekends.
new_all_months %>%
group_by(member_casual, month)%>%
summarize(number_of_rides = n())%>%
arrange(member_casual, month)%>%
ggplot(aes(x = month, y = number_of_rides, fill = member_casual)) +
labs(title = "Total Rides per Month") +
theme(axis.text.x = element_text(angle = 30)) +
geom_col(width = 0.5, position = position_dodge(width = 0.5)) +
scale_y_continuous(labels = function(x) format(x, scientific = FALSE))
From the chart we see that annual members are active from May to October, while the casual riders are active from June to August.
ggplot(data=new_all_months) + geom_bar(mapping=aes(x=rideable_type, fill=rideable_type)) + labs(title="Bike type mostly used")
From the chart now we can see that the electric bike is mostly used by the customers.
ggplot(data=new_all_months) + geom_bar(mapping=aes(x=rideable_type, fill=rideable_type))+facet_wrap(~member_casual) + labs(title="Bike type frequently used by customer type")
From the chart we see that the annual members use electric and classic bikes but majority of them use the classic bikes more, while the casual riders use the electric bike mostly compared to the other bike types.
Cyclistic annual members use the bikeshare for commuting and tasks while casual riders are using the bikeshare mostly on the weekend for longer rides and leisure.
This may make it difficult to convert casual riders to annual members, because they clearly use the bikes for different purposes
casual riders mostly use the bikeshare during the summer months, so introducing a seasonal membership program that can be upgraded to an annual membership will be a good strategy for converting casual riders to annual members.
For digital media promotion, influencers on Instagram, YouTube, Snapchat, and TikTok could be paid to share videos of their bikeshare trips around Chicago, and maybe including some of their personal favorite locations, events, views of the city. in order to lure more customers.
Cyclistic can paste stickers on the the electric bike highlighting the benefits of being an annual member, since the electric bikes are used by majority of the casual riders.
Cyclistic should advertise annual membership during the weekends, to create more awareness for the casual riders.