Scenario

Urška Sršen and Sando Mur founded Bellabeat, a high-tech company that manufactures health-focused smart products. Sršen used her background as an artist to develop beautifully designed technology that informs and inspires women around the world. Collecting data on activity, sleep, stress, and reproductive health has allowed Bellabeat to empower women with knowledge about their own health and habits. Since it was founded in 2013, Bellabeat has grown rapidly and quickly positioned itself as a tech-driven wellness company for women. Sršen knows that an analysis of Bellabeat’s available consumer data would reveal more opportunities for growth. She has asked the marketing analytics team to focus on a Bellabeat product and analyze smart device usage data in order to gain insight into how people are already using their smart devices. Then, using this information, she would like high-level recommendations for how these trends can inform Bellabeat marketing strategy.

Stakeholders

Product

Time: This wellness watch combines the timeless look of a classic timepiece with smart technology to track user activity, sleep, and stress. The Time watch connects to the Bellabeat app to provide you with insights into your daily wellness.
“The stress you might experience throughout the day is calculated taking multiple factors into account. What time you went to bed and how much sleep you got, as well as how active you’ve been and the number of steps you’ve taken play an important role in the calculation. If you’ve meditated or done any breathing exercises, and you have the reproductive health feature turned on, these values will help calculate your stress level too.” -sourced from Bellabeat’s website

Questions For Analysis

Business Task

Analyze smart device usage data from non-Bellabeat products in order to gain insight into how people are already using their smart devices and apply insights to Bellabeat marketing strategy

Description of Data Sources

FitBit Fitness Tracker Data (CC0: Public Domain, dataset made available through Mobius): This Kaggle data set contains personal fitness tracker from thirty fitbit users. Thirty eligible Fitbit users consented to the submission of personal tracker data, including minute-level output for physical activity, heart rate, and sleep monitoring. It includes information about daily activity, steps, and heart rate that can be used to explore users’ habits. There is a potential bias/credibility issue due to its small sample size, short time period, and it’s outdated. The data also comes from a different company, not direct data from Bellabeat users.

I chose to use R for my analysis because of its ability to process, clean, analyze, and make visualizations.

Preparing the Data

Packages installed and loaded:
  • tidyverse, janitor, lubridate, readr, and ggplot2
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.4
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ 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(dplyr)
library(janitor)
## 
## Attaching package: 'janitor'
## 
## The following objects are masked from 'package:stats':
## 
##     chisq.test, fisher.test
library(lubridate)
library(readr)
library(ggplot2)
Importing datasets

Out of 18 datasets, I chose to look at daily activity and sleep since Bellabeat’s Time measures activity, sleep, and stress. The watch calculates your stress based on your bedtime, activity levels, and the number of steps you take.

activity_daily <- read_csv("Case Study_FitBit Data/dailyActivity_merged.csv")
## Rows: 940 Columns: 15
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (1): ActivityDate
## dbl (14): Id, TotalSteps, TotalDistance, TrackerDistance, LoggedActivitiesDi...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
sleep_daily <- read_csv("Case Study_FitBit Data/sleepDay_merged.csv")
## Rows: 413 Columns: 5
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): SleepDay
## dbl (4): Id, TotalSleepRecords, TotalMinutesAsleep, TotalTimeInBed
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

Processing the Data

Checking unique IDs
n_distinct(activity_daily$Id)
## [1] 33
n_distinct(sleep_daily$Id)
## [1] 24
Duplicates
sum(duplicated(activity_daily))
## [1] 0
sum(duplicated(sleep_daily))
## [1] 3

Removing duplicates

sleep_daily <- sleep_daily %>%
  distinct()
sum(duplicated(sleep_daily))
## [1] 0
Cleaning the column names
activity_daily <- clean_names(activity_daily)
sleep_daily <- clean_names(sleep_daily)
View(activity_daily)
View(sleep_daily)
Checking data format
str(activity_daily)
## spc_tbl_ [940 × 15] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
##  $ id                        : num [1:940] 1.5e+09 1.5e+09 1.5e+09 1.5e+09 1.5e+09 ...
##  $ activity_date             : chr [1:940] "4/12/2016" "4/13/2016" "4/14/2016" "4/15/2016" ...
##  $ total_steps               : num [1:940] 13162 10735 10460 9762 12669 ...
##  $ total_distance            : num [1:940] 8.5 6.97 6.74 6.28 8.16 ...
##  $ tracker_distance          : num [1:940] 8.5 6.97 6.74 6.28 8.16 ...
##  $ logged_activities_distance: num [1:940] 0 0 0 0 0 0 0 0 0 0 ...
##  $ very_active_distance      : num [1:940] 1.88 1.57 2.44 2.14 2.71 ...
##  $ moderately_active_distance: num [1:940] 0.55 0.69 0.4 1.26 0.41 ...
##  $ light_active_distance     : num [1:940] 6.06 4.71 3.91 2.83 5.04 ...
##  $ sedentary_active_distance : num [1:940] 0 0 0 0 0 0 0 0 0 0 ...
##  $ very_active_minutes       : num [1:940] 25 21 30 29 36 38 42 50 28 19 ...
##  $ fairly_active_minutes     : num [1:940] 13 19 11 34 10 20 16 31 12 8 ...
##  $ lightly_active_minutes    : num [1:940] 328 217 181 209 221 164 233 264 205 211 ...
##  $ sedentary_minutes         : num [1:940] 728 776 1218 726 773 ...
##  $ calories                  : num [1:940] 1985 1797 1776 1745 1863 ...
##  - attr(*, "spec")=
##   .. cols(
##   ..   Id = col_double(),
##   ..   ActivityDate = col_character(),
##   ..   TotalSteps = col_double(),
##   ..   TotalDistance = col_double(),
##   ..   TrackerDistance = col_double(),
##   ..   LoggedActivitiesDistance = col_double(),
##   ..   VeryActiveDistance = col_double(),
##   ..   ModeratelyActiveDistance = col_double(),
##   ..   LightActiveDistance = col_double(),
##   ..   SedentaryActiveDistance = col_double(),
##   ..   VeryActiveMinutes = col_double(),
##   ..   FairlyActiveMinutes = col_double(),
##   ..   LightlyActiveMinutes = col_double(),
##   ..   SedentaryMinutes = col_double(),
##   ..   Calories = col_double()
##   .. )
##  - attr(*, "problems")=<externalptr>
str(sleep_daily)
## tibble [410 × 5] (S3: tbl_df/tbl/data.frame)
##  $ id                  : num [1:410] 1.5e+09 1.5e+09 1.5e+09 1.5e+09 1.5e+09 ...
##  $ sleep_day           : chr [1:410] "4/12/2016 12:00:00 AM" "4/13/2016 12:00:00 AM" "4/15/2016 12:00:00 AM" "4/16/2016 12:00:00 AM" ...
##  $ total_sleep_records : num [1:410] 1 2 1 2 1 1 1 1 1 1 ...
##  $ total_minutes_asleep: num [1:410] 327 384 412 340 700 304 360 325 361 430 ...
##  $ total_time_in_bed   : num [1:410] 346 407 442 367 712 320 377 364 384 449 ...
Cleaning formats
activity_daily <- activity_daily %>%
  rename(date = activity_date) %>%
  mutate(date = as_date(date,format = "%m/%d/%Y"))
sleep_daily <- sleep_daily %>%
  rename(date = sleep_day) %>%
  mutate(date = as_date(date,format = "%m/%d/%Y %I:%M:%S %p"))
str(activity_daily)
## tibble [940 × 15] (S3: tbl_df/tbl/data.frame)
##  $ id                        : num [1:940] 1.5e+09 1.5e+09 1.5e+09 1.5e+09 1.5e+09 ...
##  $ date                      : Date[1:940], format: "2016-04-12" "2016-04-13" ...
##  $ total_steps               : num [1:940] 13162 10735 10460 9762 12669 ...
##  $ total_distance            : num [1:940] 8.5 6.97 6.74 6.28 8.16 ...
##  $ tracker_distance          : num [1:940] 8.5 6.97 6.74 6.28 8.16 ...
##  $ logged_activities_distance: num [1:940] 0 0 0 0 0 0 0 0 0 0 ...
##  $ very_active_distance      : num [1:940] 1.88 1.57 2.44 2.14 2.71 ...
##  $ moderately_active_distance: num [1:940] 0.55 0.69 0.4 1.26 0.41 ...
##  $ light_active_distance     : num [1:940] 6.06 4.71 3.91 2.83 5.04 ...
##  $ sedentary_active_distance : num [1:940] 0 0 0 0 0 0 0 0 0 0 ...
##  $ very_active_minutes       : num [1:940] 25 21 30 29 36 38 42 50 28 19 ...
##  $ fairly_active_minutes     : num [1:940] 13 19 11 34 10 20 16 31 12 8 ...
##  $ lightly_active_minutes    : num [1:940] 328 217 181 209 221 164 233 264 205 211 ...
##  $ sedentary_minutes         : num [1:940] 728 776 1218 726 773 ...
##  $ calories                  : num [1:940] 1985 1797 1776 1745 1863 ...
str(sleep_daily)
## tibble [410 × 5] (S3: tbl_df/tbl/data.frame)
##  $ id                  : num [1:410] 1.5e+09 1.5e+09 1.5e+09 1.5e+09 1.5e+09 ...
##  $ date                : Date[1:410], format: "2016-04-12" "2016-04-13" ...
##  $ total_sleep_records : num [1:410] 1 2 1 2 1 1 1 1 1 1 ...
##  $ total_minutes_asleep: num [1:410] 327 384 412 340 700 304 360 325 361 430 ...
##  $ total_time_in_bed   : num [1:410] 346 407 442 367 712 320 377 364 384 449 ...

Analyze

Quick Summary Statistics
activity_daily %>%  
  select(total_steps, total_distance, sedentary_minutes) %>%
  summary()
##   total_steps    total_distance   sedentary_minutes
##  Min.   :    0   Min.   : 0.000   Min.   :   0.0   
##  1st Qu.: 3790   1st Qu.: 2.620   1st Qu.: 729.8   
##  Median : 7406   Median : 5.245   Median :1057.5   
##  Mean   : 7638   Mean   : 5.490   Mean   : 991.2   
##  3rd Qu.:10727   3rd Qu.: 7.713   3rd Qu.:1229.5   
##  Max.   :36019   Max.   :28.030   Max.   :1440.0
  • Users on average took 7,638 steps, which is less than the daily 10,000 steps recommended by the CDC
  • Users also spent 16 hours in a sedentary (non-active) state when the CDC also recommends: “The Physical Activity Guidelines for Americans recommend that adults get at least 150 minutes of moderate-intensity aerobic physical activity or 75 minutes of vigorous-intensity physical activity, or an equivalent combination each week.”
sleep_daily %>%
  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
  • Users are receiving 6 hours 54 minutes of sleep on average
  • Users are also spending 7 hours 38 minutes in bed
  • Users are laying in bed for ~40 minutes before falling asleep
  • A wind down reminder or mindfulness exercises may help reduce this time of restlessness laying in bed
Now, I’m going to merge the sleep and activity datasets to help with visualizations in the next phase of the analysis:
merged_dataset <- merge(sleep_daily,activity_daily, by=c("id", "date"), all=TRUE)
merged_dataset <- merged_dataset %>%
  mutate(total_daily_activity = very_active_minutes + fairly_active_minutes + lightly_active_minutes)

merged_dataset <- merged_dataset %>%
  mutate(total_time_worn = total_daily_activity + sedentary_minutes)
View(merged_dataset)

Making a new column for the total daily activity

merged_dataset <- merged_dataset %>%
  mutate(total_daily_activity= very_active_minutes + fairly_active_minutes + lightly_active_minutes)

Share

ggplot(data=activity_daily) +
  geom_smooth(mapping= aes(x= total_steps, y=sedentary_minutes)) +
  geom_point(mapping= aes(x=total_steps, y=sedentary_minutes)) +
  labs(title = "Sedentary Minutes & Total Steps", x= "Total Steps", y= "Sedentary Minutes")
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'

ggplot(data= sleep_daily) +
  geom_smooth(mapping= aes(x=total_time_in_bed, y=total_minutes_asleep)) +
  geom_point(mapping= aes(x=total_time_in_bed, y=total_minutes_asleep)) +
  labs(title="Sleep", x= "Time in Bed", y= "Minutes Asleep")
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'

ggplot(data=merged_dataset) +
  geom_smooth(mapping=aes(x=total_daily_activity, y=total_minutes_asleep)) +
  geom_point(mapping=aes(x=total_daily_activity, y=total_minutes_asleep)) +
  labs(title = "Relationship Between Sleep & Activity", x= "Daily Activity", y= "Minutes Asleep")
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'
## Warning: Removed 530 rows containing non-finite values (`stat_smooth()`).
## Warning: Removed 530 rows containing missing values (`geom_point()`).

Act

Findings

Recommendations

Dataset Source: MÖBIUS. 2016, May. FitBit Fitness Tracker Data, Version 1. Retrieved January 11, 2024 from https://www.kaggle.com/datasets/arashnic/fitbit/data.