Bellabeat was founded in 2013 manufacturing health-focused smart products for women. The marketing analytics team has been asked to focus on a product and analyze smart device usage data to gain insights into how customers use their product. These insights will be used to help guide the marketing strategy.
Identify trends of customers using a non-Bellabeat smart device (Fitbit) dataset to gain insights to guide Bellabeat marketing strategy. For this analysis, we will be focusing on Bellabeat’s Leaf product.
Primary stakeholders: Urška Sršen and Sando Mur, executive team
members.
Secondary stakeholders: Bellabeat marketing analytics team.
FitBit Fitness Tracker Data (CCO: Public Domain, dataset was made
available by Mobius) on Kaggle
There are 18 csv files available
Contains data for physical activity, sleep, and heart rate, with each
user having a unique ID.
Only 30 users’ data is included in the dataset, meaning the data is
most likely not representative.
The dataset is outdated and only contains two months’ worth of data. It
is also limited in that FitBits are exclusively worn as watches, whereas
the Bellabeat’s Leaf can be worn as a watch or a necklace, so the data
obtained by wearing the Leaf as a necklace could differ.
I installed the following packages and libraries to use.
install.packages('tidyverse')
install.packages('lubridate')
install.packages('ggpubr')
install.packages('janitor')
library(tidyverse)
library(lubridate)
library(ggplot2)
library(dplyr)
library(tidyr)
library(janitor)
library(readr)
Then I imported the following csv files and took an overview of them.
daily_activity <- read_csv('Fitbit_datasets/dailyActivity_merged.csv')
daily_calories <- read_csv('Fitbit_datasets/dailyCalories_merged.csv')
daily_steps <- read_csv('Fitbit_datasets/dailySteps_merged.csv')
heartrate <- read_csv('Fitbit_datasets/heartrate_seconds_merged.csv')
daily_sleep <- read_csv('Fitbit_datasets/sleepDay_merged.csv')
weight_log <- read_csv('Fitbit_datasets/weightLogInfo_merged.csv')
head(daily_activity)
head(daily_calories)
head(daily_steps)
head(heartrate)
head(daily_sleep)
head(weight_log)
The file daily_activity contains the data from the daily_calories and
daily_steps,
making them redundant, so we won’t use them.
Next, we can check on how many unique Ids are in each dataset left.
n_distinct(daily_activity$Id)
## [1] 33
n_distinct(heartrate$Id)
## [1] 14
n_distinct(daily_sleep$Id)
## [1] 24
n_distinct(weight_log$Id)
## [1] 8
As seen, the weight_log and the heartrate datasets do not have enough
unique user data to use them as part of this analysis, so we will
disregard those as well.
It is important to also note the discrepancy between the number of users
we were told the datasets had (30) and the actual number of unique IDs
listed in the data we’re using (33 and 24).
Next, I want to quickly glimpse the data to double-check what we’ve
got.
glimpse(daily_activity)
glimpse(daily_sleep)
I chose to use R to have all of my data, process, analysis, and
visuals in one place.
First, I check for any duplicates.
sum(duplicated(daily_activity))
## [1] 0
sum(duplicated(daily_sleep))
## [1] 3
Since only the daily sleep has duplicates, we’ll remove those.
daily_sleep <- daily_sleep %>%
distinct() %>%
drop_na()
Then I verify the duplicates were dropped.
sum(duplicated(daily_sleep))
## [1] 0
Next, I’ll clean up the column names to ensure they’re all lowercase and consistent.
clean_daily_activity <- daily_activity %>%
clean_names()
clean_daily_sleep <- daily_sleep %>%
clean_names()
The columns recording the dates in each data set are labeled differently, so I will change them to be the same.
colnames(clean_daily_sleep)[colnames(clean_daily_sleep) == "sleep_day"] = "activity_date"
In addition, both datasets have these columns as character format, so I convert them to date format.
clean_daily_activity <- clean_daily_activity %>%
mutate(activity_date = as.POSIXct(activity_date, format = "%m/%d/%Y"))
clean_daily_sleep <- clean_daily_sleep %>%
mutate(activity_date = as.POSIXct(activity_date, format ="%m/%d/%Y %I:%M:%S %p" , tz=Sys.timezone()))
I also will separate the date and time from the clean_daily_sleep data into two separate columns.
clean_daily_sleep <- clean_daily_sleep %>%
separate(activity_date, into=c("activity_date", "sleep_time"), sep= " ")
Next, I take a look at the summary of both datasets before merging them.
clean_daily_activity %>%
select(total_steps, total_distance, calories) %>%
summary()
## total_steps total_distance calories
## Min. : 0 Min. : 0.000 Min. : 0
## 1st Qu.: 3790 1st Qu.: 2.620 1st Qu.:1828
## Median : 7406 Median : 5.245 Median :2134
## Mean : 7638 Mean : 5.490 Mean :2304
## 3rd Qu.:10727 3rd Qu.: 7.713 3rd Qu.:2793
## Max. :36019 Max. :28.030 Max. :4900
The average number of steps taken per day is 7,638. Average number of calories consumed is 2,304.
clean_daily_sleep %>%
select(total_sleep_records, total_minutes_asleep, total_time_in_bed) %>%
summary()
## total_sleep_records total_minutes_asleep total_time_in_bed
## Min. :1.00 Min. : 58.0 Min. : 61.0
## 1st Qu.:1.00 1st Qu.:361.0 1st Qu.:403.8
## Median :1.00 Median :432.5 Median :463.0
## Mean :1.12 Mean :419.2 Mean :458.5
## 3rd Qu.:1.00 3rd Qu.:490.0 3rd Qu.:526.0
## Max. :3.00 Max. :796.0 Max. :961.0
Looking at the clean_daily_sleep data, one user spent 16 hours in bed, and most users are falling asleep almost as soon as they get into bed. This data does not account for injuries or disabilities, nor does it look at night-time routines.
Finally, I can merge the datasets.
clean_daily_activity_sleep <- merge(clean_daily_activity, clean_daily_sleep, by=c("id"),all=TRUE)
There are many limitations to this dataset, which Bellabeat should
keep in mind.
Many of the users are sedentary or not very active, and they would
benefit from fun reminders and being able to set individual goals to
motivate them to move more.
Sleep and activity do not seem to affect the other, though I would
recommend gathering more data to verify the accuracy of this.
Adding reminders for bedtime, along with relaxation aids like breathing
and nature or other calming sound recordings, would aid users in
improving the quality and length of their sleep.
In my first case study and first project using R, I learned how to find the answers to various questions and problems, not just what the analysis was answering. I found myself more confident in analyzing the data since I was able to use resources like Google, R Community, and others who have more experience using R. I’m looking forward to working on more case studies and using my skills.