This case evaluates Cyclistic bike-share product for a fictional company, Cyclistic.
The main objective in this analysis was to evaluate the behavior of two types of users of Cyclist services, member users that have a annual membership plan and casual users that acquire single rides. It was evaluated different parameters such as ride type (classic, electrical, docked), ride duration, weekday, month, hour of the day. Considering this variables, it was observed different behaviors in this two type of users in order to give a direction for Marketing team to increase the member users.
Cyclistic, a successful bike-share company in Chicago, operates over 5,800 bikes and 600 docking stations geotracked and locked in a network citywide. The bikes are interchangeable across stations, offering flexibility to users.
Distinguishing itself by providing reclining bikes, hand tricycles, and cargo bikes, Cyclistic aims to be inclusive to those with disabilities and riders unable to use standard two-wheeled bikes. While most riders prefer traditional bikes, 8% use assistive options. Cyclistic’s user base enjoys leisure rides, with 30% utilizing bikes for daily commutes. The type of users are casual riders that buy single-ride or full-day passes, while members enjoy Cyclistic’s membership with annual plan.
Financial analysis reveals that annual members are more profitable. Despite the success of pricing plans, maximizing annual memberships is crucial for future growth. Rather than targeting new customers, the goal is to convert existing casual riders who are already familiar with Cyclistic.
The marketing team objective is to develop marketing strategies to convert casual riders into annual members. To achieve this, the team needs a deeper understanding of the differences between annual members and casual riders, motivations for casual riders to buy a membership, and the impact of digital media on marketing tactics.
For this case the objective is to have a better understanding of different behaviors between members and casual riders, in order to achieve the strategic plan for converting casual riders to member riders.
Therefore, the problem statement that will be answered is:
How do annual members and casual riders use Cyclistic bikes differently?
All data was made available in the case study for Google Data Analytics Capstone Course by Motivate International Inc.
Data was download and stored locally in the link https://divvy-tripdata.s3.amazonaws.com/index.html.
The data license can be found here https://divvybikes.com/data-license-agreement.
For the analysis, it was download and evaluated the data from August-2021 to July-2023.
Load raw data from local file. Upload of data can be checked in details in append.
load(file="./tripdf_rawdata.Rda")
packages <- c("ggplot2", "dplyr","geosphere","tidyverse","knitr")
lapply(packages, require, character.only = TRUE)
Sys.setlocale("LC_TIME", "en_US") #Change language to English
rm(packages)
Data description:
str(tripdf_rawdata)
## 'data.frame': 11625069 obs. of 13 variables:
## $ ride_id : chr "99103BB87CC6C1BB" "EAFCCCFB0A3FC5A1" "9EF4F46C57AD234D" "5834D3208BFAF1DA" ...
## $ rideable_type : chr "electric_bike" "electric_bike" "electric_bike" "electric_bike" ...
## $ started_at : chr "2021-08-10 17:15:49" "2021-08-10 17:23:14" "2021-08-21 02:34:23" "2021-08-21 06:52:55" ...
## $ ended_at : chr "2021-08-10 17:22:44" "2021-08-10 17:39:24" "2021-08-21 02:50:36" "2021-08-21 07:08:13" ...
## $ start_station_name: chr "" "" "" "" ...
## $ start_station_id : chr "" "" "" "" ...
## $ end_station_name : chr "" "" "" "" ...
## $ end_station_id : chr "" "" "" "" ...
## $ start_lat : num 41.8 41.8 42 42 41.8 ...
## $ start_lng : num -87.7 -87.7 -87.7 -87.7 -87.6 ...
## $ end_lat : num 41.8 41.8 42 42 41.8 ...
## $ end_lng : num -87.7 -87.6 -87.7 -87.7 -87.6 ...
## $ member_casual : chr "member" "member" "member" "member" ...
Data summary:
summary(tripdf_rawdata)
## ride_id rideable_type started_at ended_at
## Length:11625069 Length:11625069 Length:11625069 Length:11625069
## Class :character Class :character Class :character Class :character
## Mode :character Mode :character Mode :character Mode :character
##
##
##
##
## start_station_name start_station_id end_station_name end_station_id
## Length:11625069 Length:11625069 Length:11625069 Length:11625069
## Class :character Class :character Class :character Class :character
## Mode :character Mode :character Mode :character Mode :character
##
##
##
##
## start_lat start_lng end_lat end_lng
## Min. :41.64 Min. :-87.92 Min. : 0.00 Min. :-88.97
## 1st Qu.:41.88 1st Qu.:-87.66 1st Qu.:41.88 1st Qu.:-87.66
## Median :41.90 Median :-87.64 Median :41.90 Median :-87.64
## Mean :41.90 Mean :-87.65 Mean :41.90 Mean :-87.65
## 3rd Qu.:41.93 3rd Qu.:-87.63 3rd Qu.:41.93 3rd Qu.:-87.63
## Max. :45.64 Max. :-73.80 Max. :42.37 Max. : 0.00
## NA's :11692 NA's :11692
## member_casual
## Length:11625069
## Class :character
## Mode :character
##
##
##
##
# NA values
na_summary <- sapply(tripdf_rawdata, function(x) sum(is.na(x))) #NA count per column
# Empty Values
empty_summary <- sapply(tripdf_rawdata, function(x) length(which(x == ""))) #Distinct count per column
# Distinct observations
dis_summary <- sapply(tripdf_rawdata, function(x) n_distinct(x)) #Distinct count per column
NA: maximum NA in one column values represents 0.1 % of total data - Insignificant cases with NA values
Empty Values represents 15.87 % of data in one variable.
Data also shows different station names for the same station id.
The following tasks were done in the raw data: - Filter out observations with NA values. - Transform date class of started_at column. - Create columns for months, hour of the day that the ride started, weekday of the ride, and ride duration in minutes. - Remove latitude and longitude columns.
tripdf_tidydata <- tripdf_rawdata %>% filter(complete.cases(.))
tripdf_tidydata$started_at <- as.POSIXct(tripdf_tidydata$started_at)
tripdf_tidydata$date <- as.Date(tripdf_tidydata$started_at, tz = "EST")
tripdf_tidydata <- tripdf_tidydata %>%
mutate(month = format(started_at, "%Y-%m"),
hour = lubridate::hour(started_at),
weekday = weekdays(started_at),
ride_duration_min = as.double(difftime(ended_at,started_at, units="mins")))
tripdf_tidydata$member_casual <- as.factor(tripdf_tidydata$member_casual)
tripdf_tidydata$rideable_type <- as.factor(tripdf_tidydata$rideable_type)
tripdf_tidydata$weekday <- factor(tripdf_tidydata$weekday, levels=c("Sunday", "Monday", "Tuesday","Wednesday","Thursday","Friday","Saturday"))
tripdf_tidydata <- tripdf_tidydata %>%
mutate(weekday_type = case_when(weekday == 'Sunday' | weekday == 'Saturday' ~ 'Weekend', .default = 'Weekday'))
tripdf_tidydata <- tripdf_tidydata %>%
select(-start_lat,-start_lng,-end_lat,-end_lng)
tripdf_tidydata_full <- tripdf_tidydata
In order to check the necessity of using all the two years period data, a preliminary exploratory analysis was done to evaluate the trend of quantity of rides per type of user in this period.
## Preliminary Exploratory Analysis
trips_monthly <- tripdf_tidydata_full %>%
select(month,member_casual) %>%
group_by(month,member_casual) %>%
summarise(count = n())
ggplot(trips_monthly,aes(x=month, y=count/1000, group = member_casual, color = member_casual)) +
geom_line()+geom_point() +
theme(axis.text.x = element_text(face = "bold",angle=90),
legend.position="bottom",
legend.title = element_blank()) +
ylab("Rides (*10^3)]")+xlab("")
There is a cyclical trend for both type of users, with a higher decrease of casual riders in winter season, December to February. It will be narrowed the data for just a one year period. Furthermore, it will be removed outliers from rides duration.
tripdf_tidydata <- tripdf_tidydata %>%
filter(date >= '2022-08-01') %>%
filter(ride_duration_min >= 1 & ride_duration_min <= 120)
Split of type of user per bike type. Casual riders have more preference for electric bikes, and member users don’t use docked bikes.
user_rideable_tbl <- table(tripdf_tidydata$rideable_type, tripdf_tidydata$member_casual)
user_rideable_tbl <- prop.table(user_rideable_tbl, margin = 2) * 100
user_rideable_df <- as.data.frame.matrix(user_rideable_tbl)
colnames(user_rideable_df) <- c("Casual (%)", "Member (%)")
print(round(user_rideable_df, 1))
## Casual (%) Member (%)
## classic_bike 36.6 48.2
## docked_bike 5.5 0.0
## electric_bike 57.8 51.8
ggplot(tripdf_tidydata,aes(x=(member_casual), fill=rideable_type)) +
geom_bar(position = "stack")+xlab("")+ylab("Rides") +
theme(axis.text.x = element_text(face = "bold"),
legend.title = element_blank()) +
scale_fill_brewer(palette = "Set1")
avgrides_per_wkday <- tripdf_tidydata %>%
group_by(weekday,member_casual) %>%
summarise(avg_rides = n() / n_distinct(date))
ggplot(avgrides_per_wkday, aes(x = weekday, y = avg_rides, fill = member_casual)) +
geom_col(position = "dodge", alpha = 0.7) +
labs(x = "",
y = "Average of Rides per day",
fill = "") +
scale_fill_brewer(palette = "Set1")
avg_wkdaytyp <- table(tripdf_tidydata$weekday_type, tripdf_tidydata$member_casual)
avg_wkdaytyp_per <- prop.table(avg_wkdaytyp, margin = 1) * 100
avg_wkdaytyp_per_df <- as.data.frame.matrix(avg_wkdaytyp_per)
colnames(avg_wkdaytyp_per_df) <- c("Casual (%)", "Member (%)")
print(round(avg_wkdaytyp_per_df, 1))
## Casual (%) Member (%)
## Weekday 33.9 66.1
## Weekend 47.2 52.8
In average, casual users have higher riders than member users. The most common duration of ride duration is around 4 minutes and casual is 7 minutes. besides this difference the shape of the curve is really similar for both type of users.
#Function to find mode
getmode <- function(v) {
uniqv <- unique(v)
uniqv[which.max(tabulate(match(v, uniqv)))]
}
ride_duration_df <- tripdf_tidydata %>%
group_by(member_casual) %>%
summarise(
mean_duration = mean(ride_duration_min, na.rm = TRUE),
Q1 = quantile(ride_duration_min, 0.25, na.rm = TRUE),
median = quantile(ride_duration_min, 0.5, na.rm = TRUE),
Q3 = quantile(ride_duration_min, 0.75, na.rm = TRUE),
min_duration = min(ride_duration_min, na.rm = TRUE),
max_duration = max(ride_duration_min, na.rm = TRUE),
mode = getmode(ride_duration_min)
)
print(ride_duration_df)
## # A tibble: 2 Ă— 8
## member_casual mean_duration Q1 median Q3 min_duration max_duration mode
## <fct> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 casual 17.9 6.95 12 21.8 1 120 6.55
## 2 member 11.8 5.18 8.73 14.8 1 120 4.32
ggplot(tripdf_tidydata, aes(x = ride_duration_min, fill = member_casual)) +
geom_histogram(binwidth = 0.5, position = "identity", alpha = 0.7) +
labs(title = "",
x = "Ride Duration (min)",
y = "",
fill = "") +
xlim(0,50) +
scale_fill_brewer(palette = "Set1")
From the evaluation of day time for rides between the two types of user we can Members during weekdays concentred rides between 7:00 and 8:00, and also from 17:00 to 18:00. During weekends more disperse between 12:00 and 17:00, but much lower than weekdays.
# Count occurrences of each hour per weekday
hour_counts_member <- tripdf_tidydata %>% filter(member_casual == "member") %>%
group_by(weekday, hour) %>%
summarise(count = n())
# Create the heatmap
ggplot(hour_counts_member, aes(x = factor(weekday), y = hour, fill = count)) +
geom_tile() +
scale_fill_gradient(low = "white", high = "blue") +
labs(title = "Member Rides Heatmap",
x = "",
y = "Day Time") +
guides(fill = FALSE)+
theme_minimal()
hour_counts_casual <- tripdf_tidydata %>% filter(member_casual == "casual") %>%
group_by(weekday, hour) %>%
summarise(count = n())
ggplot(hour_counts_casual, aes(x = factor(weekday), y = hour, fill = count)) +
geom_tile() +
scale_fill_gradient(low = "white", high = "blue") +
labs(title = "Casual Rides Heatmap",
x = "",
y = "Day Time") +
guides(fill = FALSE)+
theme_minimal()
This trend during weekdays is interesting because shows some aspects that people use more or lower bike share product. Probably, this trips are to commute to work or school at 8:00 and 17:00. Casual riders probably use only to return (18:00). One indication is that this people don’t have a place to exchange clothes and prefer only to return.
commute_df <- tripdf_tidydata %>%
filter(weekday_type == 'Weekday' & ((hour >= 7 & hour <= 9) | (hour >= 16 & hour <= 18 ))) %>%
group_by(member_casual) %>%
count()
total_df <- tripdf_tidydata %>%
group_by(member_casual) %>%
count()
The behavior of each group can be defined as follow:
Member:
Uses electric and classic bike. Do more rides during weekdays to commute, during the morning from 7:00 to 9:00 and in the evening from 16:00 to 18:00. Around 36% of the rides from member users are to commute. Average of distance duration is around
Casual Uses more electric bikes than classic bikes. A small portion also uses docked bikes. The highest number of casual riders happens during the weekend. During week days it is observed a similar pattern of casual riders using to commute, but more expressive in the evening only. The variation of casual rides is much higher than member rides during the year. It is observed a reduction around XXX.
The most significant behavior that is observed is the difference of usage during weekdays and weekend between member and casual rides. Also the concentration of rides in some day time during the week days shows probably more usage for commute propose than leisure.
It is observed some difference between usage of
It would be nice to have a rider id information in order to get some information: - How is the average and dispersion of travels for members and casual riders - There are two types of casual riders: Casual that use to little (once/twice per month) and orders that have at least one ride per week?
Data upload from local folder.
file_list <- list.files(path = "./Data/Excel_files", pattern = "*.csv", full.names = TRUE)
# Initialize an empty list to store the data frames
df_list <- list()
# Loop through each file and read it into a data frame
for(file in file_list) {
df <- read.csv(file)
df_list[[file]] <- df
}
# Combine all data frames into one
tripdf_rawdata <- do.call(rbind, df_list) #Raw data of all files
rm(df,df_list,file,file_list)