The Bellabeat Company has its Time wellness watch, which connects to the Bellabeat App. It uses smart technology to track users activity, sleep and stress.The stake holders wants data analyst to analyze smart device usage data in order to gain insight into how consumers use non-Bellabeat smart devices.
So Time watch, one of Bellabeat’s products, is used to apply the insights in this presentation.
install.packages("tidyverse")
install.packages("here")
install.packages("skimr")
install.packages("janitor")
install.packages("dplyr")
install.packages("tidyr")
library(tidyverse)
library(here)
library(skimr)
library(janitor)
library(dplyr)
library(tidyr)
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. The following 3 data sets are used -
dataset_activity <- read_csv("/cloud/project/CaseStudy20240306/Datasets/Dataset1/dailyActivity_merged.csv")
#View(dataset_activity)
The dataset_activity data set details the following variables (column names are self explanatory) to measure the activity level.
colnames(dataset_activity)
## [1] "Id" "ActivityDate"
## [3] "TotalSteps" "TotalDistance"
## [5] "TrackerDistance" "LoggedActivitiesDistance"
## [7] "VeryActiveDistance" "ModeratelyActiveDistance"
## [9] "LightActiveDistance" "SedentaryActiveDistance"
## [11] "VeryActiveMinutes" "FairlyActiveMinutes"
## [13] "LightlyActiveMinutes" "SedentaryMinutes"
## [15] "Calories"
dataset_heartrate <- read_csv("/cloud/project/CaseStudy20240306/Datasets/Dataset1/heartrate_seconds_merged.csv")
The dataset_heartrate data set details the following variables (column names are self explanatory) to measure the stress level.
colnames(dataset_heartrate)
## [1] "Id" "Time" "Value"
dataset_minuteSleep <- read_csv("/cloud/project/CaseStudy20240306/Datasets/Dataset1/minuteSleep_merged.csv")
#View(dataset_minuteSleep)
The dataset_minuteSleep data set details the following variables (column names are self explanatory) to measure the sleep level.
colnames(dataset_minuteSleep)
## [1] "Id" "date" "value" "logId"
To make sure it has only characters, numbers and underscores in them
# clean column names to make sure it has only characters, numbers and underscores in them
clean_names(dataset_activity)
## # A tibble: 457 × 15
## id activity_date total_steps total_distance tracker_distance
## <dbl> <chr> <dbl> <dbl> <dbl>
## 1 1503960366 3/25/2016 11004 7.11 7.11
## 2 1503960366 3/26/2016 17609 11.6 11.6
## 3 1503960366 3/27/2016 12736 8.53 8.53
## 4 1503960366 3/28/2016 13231 8.93 8.93
## 5 1503960366 3/29/2016 12041 7.85 7.85
## 6 1503960366 3/30/2016 10970 7.16 7.16
## 7 1503960366 3/31/2016 12256 7.86 7.86
## 8 1503960366 4/1/2016 12262 7.87 7.87
## 9 1503960366 4/2/2016 11248 7.25 7.25
## 10 1503960366 4/3/2016 10016 6.37 6.37
## # ℹ 447 more rows
## # ℹ 10 more variables: logged_activities_distance <dbl>,
## # very_active_distance <dbl>, moderately_active_distance <dbl>,
## # light_active_distance <dbl>, sedentary_active_distance <dbl>,
## # very_active_minutes <dbl>, fairly_active_minutes <dbl>,
## # lightly_active_minutes <dbl>, sedentary_minutes <dbl>, calories <dbl>
# clean column names to make sure it has only characters, numbers and underscores in them
clean_names(dataset_heartrate)
## # A tibble: 1,154,681 × 3
## id time value
## <dbl> <chr> <dbl>
## 1 2022484408 4/1/2016 7:54:00 AM 93
## 2 2022484408 4/1/2016 7:54:05 AM 91
## 3 2022484408 4/1/2016 7:54:10 AM 96
## 4 2022484408 4/1/2016 7:54:15 AM 98
## 5 2022484408 4/1/2016 7:54:20 AM 100
## 6 2022484408 4/1/2016 7:54:25 AM 101
## 7 2022484408 4/1/2016 7:54:30 AM 104
## 8 2022484408 4/1/2016 7:54:35 AM 105
## 9 2022484408 4/1/2016 7:54:45 AM 102
## 10 2022484408 4/1/2016 7:54:55 AM 106
## # ℹ 1,154,671 more rows
# clean column names to make sure it has only characters, numbers and underscores in them
clean_names(dataset_minuteSleep)
## # A tibble: 198,559 × 4
## id date value log_id
## <dbl> <chr> <dbl> <dbl>
## 1 1503960366 3/13/2016 2:39:30 AM 1 11114919637
## 2 1503960366 3/13/2016 2:40:30 AM 1 11114919637
## 3 1503960366 3/13/2016 2:41:30 AM 1 11114919637
## 4 1503960366 3/13/2016 2:42:30 AM 1 11114919637
## 5 1503960366 3/13/2016 2:43:30 AM 1 11114919637
## 6 1503960366 3/13/2016 2:44:30 AM 1 11114919637
## 7 1503960366 3/13/2016 2:45:30 AM 2 11114919637
## 8 1503960366 3/13/2016 2:46:30 AM 2 11114919637
## 9 1503960366 3/13/2016 2:47:30 AM 1 11114919637
## 10 1503960366 3/13/2016 2:48:30 AM 1 11114919637
## # ℹ 198,549 more rows
# rename a column as "Time" is also a reserved word
dataset_heartrate_rename_column<-rename(dataset_heartrate, DateTime = Time)
colnames(dataset_heartrate_rename_column)
## [1] "Id" "DateTime" "Value"
To make it easy to work with
# Smaller version of heartrate dataset - 50000 records
dataset_heartrate_small <- dataset_heartrate_rename_column[-c(50001:1154681), ]
# separating date, time and AM/PM
dataset_heartrate_mod <- separate_wider_delim(dataset_heartrate_small, DateTime, delim = " ", names = c("date", "time", "AM/PM"))
colnames(dataset_heartrate_mod)
## [1] "Id" "date" "time" "AM/PM" "Value"
# Smaller version of sleep dataset - 50000 records
dataset_minuteSleep_small <- dataset_minuteSleep[-c(50001:1154681), ]
#View(dataset_minuteSleep_small)
# to determine the average value by Id
dataset_heartrate_by_date <- dataset_heartrate_mod %>%
group_by(date) %>%
na.omit() %>% # to remove empty data (rows)
summarise(avg_value = mean(Value))
#View(dataset_heartrate_by_date)
ggplot(data = dataset_heartrate_by_date) +
geom_point(mapping = aes(x = date, y = avg_value, color=date, shape=date)) +
ggtitle("Stress Level by Date") +
xlab("Date") + ylab("Average Value") +
annotate("text", x=3, y=89, label="Highest Stress", color="red", fontface="bold", size=5)
ggplot(data = dataset_heartrate_by_date) +
geom_point(mapping = aes(x = date, y = avg_value, color=date, shape=date)) +
facet_wrap(~avg_value) +
ggtitle("Stress Level by Date in Separate Sections by Average Value") +
xlab("Date") + ylab("Average Value")
ggplot(data = dataset_activity) +
geom_smooth(mapping = aes(x = ActivityDate, y = TotalSteps, linetype=ActivityDate), color="blue") +
geom_point(mapping = aes(x = ActivityDate, y = TotalSteps, color=ActivityDate)) +
ggtitle("Activity by Date") +
xlab("Date") + ylab("Total Steps")
ggplot(data = dataset_minuteSleep_small, aes(x = value, y = Id, fill=Id)) +
geom_bar(stat="identity") +
ggtitle("Sleep Quality by Minutes") +
xlab("Minutes") + ylab("Id")
All the three tables are joined using Tableau, where “Id” is the Primary Key and “Value” is the Foreign Key.
knitr::include_graphics("tableau.png")
Tableau Output
On a certain date, in this case April 1st, 2016, the stress level was very high. We need to investigate as whether it was a holiday and people were having party and other fun, or some big incident happened in the family or nation wide. Also from the activity chart, it is clear that during that period, number of steps is also on the higher side. So further investigation is also needed as what was happening around that first week of April, 2016. To determine the sleep quality during that particular period, the data for that period is missing. So more data around that time, is needed.
The sale of Time watch, one of Bellabeat’s products, should be focused and marketed based on some specific evenful dates in the calendar. Consumers who are concerned about their health, most probably will consider buying this product to focus more on their health.