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.
Based on usage patterns of smart devices, identify potential areas for growth and offer suggestions for improving the Bellabeat marketing strategy.
Installing packages in RStudio.
install.packages("tidyverse")
## Installing package into '/home/rstudio-user/R/x86_64-pc-linux-gnu-library/4.2'
## (as 'lib' is unspecified)
install.packages("dplyr")
## Installing package into '/home/rstudio-user/R/x86_64-pc-linux-gnu-library/4.2'
## (as 'lib' is unspecified)
install.packages("ggplot2")
## Installing package into '/home/rstudio-user/R/x86_64-pc-linux-gnu-library/4.2'
## (as 'lib' is unspecified)
Loading the packages.
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ ggplot2 3.3.6 ✔ purrr 0.3.4
## ✔ tibble 3.1.8 ✔ dplyr 1.0.9
## ✔ tidyr 1.2.0 ✔ stringr 1.4.1
## ✔ readr 2.1.2 ✔ forcats 0.5.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
library(dplyr)
library(ggplot2)
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.
sleep_data <- read.csv("sleepDay_merged.csv")
activity_data <- read.csv("dailyActivity_merged.csv")
intensity_data <- read.csv("hourlyIntensities_merged.csv")
From the given dataset, three files have been taken to analyze the trends
head(sleep_data)
## Id SleepDay TotalSleepRecords TotalMinutesAsleep
## 1 1503960366 4/12/2016 12:00:00 AM 1 327
## 2 1503960366 4/13/2016 12:00:00 AM 2 384
## 3 1503960366 4/15/2016 12:00:00 AM 1 412
## 4 1503960366 4/16/2016 12:00:00 AM 2 340
## 5 1503960366 4/17/2016 12:00:00 AM 1 700
## 6 1503960366 4/19/2016 12:00:00 AM 1 304
## TotalTimeInBed
## 1 346
## 2 407
## 3 442
## 4 367
## 5 712
## 6 320
head(activity_data)
## Id ActivityDate TotalSteps TotalDistance TrackerDistance
## 1 1503960366 4/12/2016 13162 8.50 8.50
## 2 1503960366 4/13/2016 10735 6.97 6.97
## 3 1503960366 4/14/2016 10460 6.74 6.74
## 4 1503960366 4/15/2016 9762 6.28 6.28
## 5 1503960366 4/16/2016 12669 8.16 8.16
## 6 1503960366 4/17/2016 9705 6.48 6.48
## LoggedActivitiesDistance VeryActiveDistance ModeratelyActiveDistance
## 1 0 1.88 0.55
## 2 0 1.57 0.69
## 3 0 2.44 0.40
## 4 0 2.14 1.26
## 5 0 2.71 0.41
## 6 0 3.19 0.78
## LightActiveDistance SedentaryActiveDistance VeryActiveMinutes
## 1 6.06 0 25
## 2 4.71 0 21
## 3 3.91 0 30
## 4 2.83 0 29
## 5 5.04 0 36
## 6 2.51 0 38
## FairlyActiveMinutes LightlyActiveMinutes SedentaryMinutes Calories
## 1 13 328 728 1985
## 2 19 217 776 1797
## 3 11 181 1218 1776
## 4 34 209 726 1745
## 5 10 221 773 1863
## 6 20 164 539 1728
head(intensity_data)
## Id ActivityHour TotalIntensity AverageIntensity
## 1 1503960366 4/12/2016 12:00:00 AM 20 0.333333
## 2 1503960366 4/12/2016 1:00:00 AM 8 0.133333
## 3 1503960366 4/12/2016 2:00:00 AM 7 0.116667
## 4 1503960366 4/12/2016 3:00:00 AM 0 0.000000
## 5 1503960366 4/12/2016 4:00:00 AM 0 0.000000
## 6 1503960366 4/12/2016 5:00:00 AM 0 0.000000
The timestamp data is different in each dataframe. Converting to same date-time format.
sleep_data$SleepDay=as.POSIXct(sleep_data$SleepDay, format="%m/%d/%Y %I:%M:%S %p" , tz=Sys.timezone())
sleep_data$date <- as.Date(sleep_data$SleepDay, format = "%m/%d/%Y")
activity_data$date <- as.Date(activity_data$ActivityDate, format = "%m/%d/%Y")
intensity_data$ActivityHour=as.POSIXct(intensity_data$ActivityHour, format="%m/%d/%Y %I:%M:%S %p", tz=Sys.timezone())
intensity_data$time <- format(intensity_data$ActivityHour, format = "%H:%M:%S")
intensity_data$date <- as.Date(intensity_data$ActivityHour, format = "%m/%d/%y")
head(sleep_data)
## Id SleepDay TotalSleepRecords TotalMinutesAsleep TotalTimeInBed
## 1 1503960366 2016-04-12 1 327 346
## 2 1503960366 2016-04-13 2 384 407
## 3 1503960366 2016-04-15 1 412 442
## 4 1503960366 2016-04-16 2 340 367
## 5 1503960366 2016-04-17 1 700 712
## 6 1503960366 2016-04-19 1 304 320
## date
## 1 2016-04-12
## 2 2016-04-13
## 3 2016-04-15
## 4 2016-04-16
## 5 2016-04-17
## 6 2016-04-19
head(activity_data)
## Id ActivityDate TotalSteps TotalDistance TrackerDistance
## 1 1503960366 4/12/2016 13162 8.50 8.50
## 2 1503960366 4/13/2016 10735 6.97 6.97
## 3 1503960366 4/14/2016 10460 6.74 6.74
## 4 1503960366 4/15/2016 9762 6.28 6.28
## 5 1503960366 4/16/2016 12669 8.16 8.16
## 6 1503960366 4/17/2016 9705 6.48 6.48
## LoggedActivitiesDistance VeryActiveDistance ModeratelyActiveDistance
## 1 0 1.88 0.55
## 2 0 1.57 0.69
## 3 0 2.44 0.40
## 4 0 2.14 1.26
## 5 0 2.71 0.41
## 6 0 3.19 0.78
## LightActiveDistance SedentaryActiveDistance VeryActiveMinutes
## 1 6.06 0 25
## 2 4.71 0 21
## 3 3.91 0 30
## 4 2.83 0 29
## 5 5.04 0 36
## 6 2.51 0 38
## FairlyActiveMinutes LightlyActiveMinutes SedentaryMinutes Calories date
## 1 13 328 728 1985 2016-04-12
## 2 19 217 776 1797 2016-04-13
## 3 11 181 1218 1776 2016-04-14
## 4 34 209 726 1745 2016-04-15
## 5 10 221 773 1863 2016-04-16
## 6 20 164 539 1728 2016-04-17
head(intensity_data)
## Id ActivityHour TotalIntensity AverageIntensity time
## 1 1503960366 2016-04-12 00:00:00 20 0.333333 00:00:00
## 2 1503960366 2016-04-12 01:00:00 8 0.133333 01:00:00
## 3 1503960366 2016-04-12 02:00:00 7 0.116667 02:00:00
## 4 1503960366 2016-04-12 03:00:00 0 0.000000 03:00:00
## 5 1503960366 2016-04-12 04:00:00 0 0.000000 04:00:00
## 6 1503960366 2016-04-12 05:00:00 0 0.000000 05:00:00
## date
## 1 2016-04-12
## 2 2016-04-12
## 3 2016-04-12
## 4 2016-04-12
## 5 2016-04-12
## 6 2016-04-12
sleep_data %>%
mutate(TotalHoursAsleep = TotalMinutesAsleep/60) %>%
mutate(TotalHoursInBed = TotalTimeInBed/60) %>%
mutate(TimeToSleep = TotalTimeInBed-TotalMinutesAsleep) %>%
select(TotalHoursAsleep,
TotalHoursInBed,
TimeToSleep) %>%
drop_na() %>%
summary()
## TotalHoursAsleep TotalHoursInBed TimeToSleep
## Min. : 0.9667 Min. : 1.017 Min. : 0.00
## 1st Qu.: 6.0167 1st Qu.: 6.717 1st Qu.: 17.00
## Median : 7.2167 Median : 7.717 Median : 25.00
## Mean : 6.9911 Mean : 7.644 Mean : 39.17
## 3rd Qu.: 8.1667 3rd Qu.: 8.767 3rd Qu.: 40.00
## Max. :13.2667 Max. :16.017 Max. :371.00
activity_data %>%
select(TotalSteps,
TotalDistance,
Calories) %>%
summary()
## TotalSteps TotalDistance 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
On the average, participants sleep for 7 hours and spend 30-40 minutes on bed to fall asleep.
The average amount of distance covered by the participants around 5.5 miles which leads to burning around 2304 calories on average.
sleep_data <- mutate(sleep_data,TimeToSleep = TotalTimeInBed-TotalMinutesAsleep)
combined_data <- merge(sleep_data, activity_data, by.x = c("Id","SleepDay"), by.y = c("Id","date"))
new_int_data <- intensity_data %>%
group_by(Id,date) %>%
summarise(avg_int_per_day = mean(TotalIntensity)) %>%
mutate(avg_int_per_day = avg_int_per_day)
## `summarise()` has grouped output by 'Id'. You can override using the `.groups`
## argument.
new_combined_data <- merge(combined_data, new_int_data, by.x = c("Id", "SleepDay"), by.y = c("Id", "date"))
head(new_combined_data)
## Id SleepDay TotalSleepRecords TotalMinutesAsleep TotalTimeInBed
## 1 1503960366 2016-04-12 1 327 346
## 2 1503960366 2016-04-13 2 384 407
## 3 1503960366 2016-04-15 1 412 442
## 4 1503960366 2016-04-16 2 340 367
## 5 1503960366 2016-04-17 1 700 712
## 6 1503960366 2016-04-19 1 304 320
## date TimeToSleep ActivityDate TotalSteps TotalDistance TrackerDistance
## 1 2016-04-12 19 4/12/2016 13162 8.50 8.50
## 2 2016-04-13 23 4/13/2016 10735 6.97 6.97
## 3 2016-04-15 30 4/15/2016 9762 6.28 6.28
## 4 2016-04-16 27 4/16/2016 12669 8.16 8.16
## 5 2016-04-17 12 4/17/2016 9705 6.48 6.48
## 6 2016-04-19 16 4/19/2016 15506 9.88 9.88
## LoggedActivitiesDistance VeryActiveDistance ModeratelyActiveDistance
## 1 0 1.88 0.55
## 2 0 1.57 0.69
## 3 0 2.14 1.26
## 4 0 2.71 0.41
## 5 0 3.19 0.78
## 6 0 3.53 1.32
## LightActiveDistance SedentaryActiveDistance VeryActiveMinutes
## 1 6.06 0 25
## 2 4.71 0 21
## 3 2.83 0 29
## 4 5.04 0 36
## 5 2.51 0 38
## 6 5.03 0 50
## FairlyActiveMinutes LightlyActiveMinutes SedentaryMinutes Calories
## 1 13 328 728 1985
## 2 19 217 776 1797
## 3 34 209 726 1745
## 4 10 221 773 1863
## 5 20 164 539 1728
## 6 31 264 775 2035
## avg_int_per_day
## 1 17.87500
## 2 13.25000
## 3 15.16667
## 4 14.54167
## 5 13.25000
## 6 19.83333
ggplot(data = new_combined_data, mapping = aes(avg_int_per_day,Calories))+geom_point()+
geom_smooth(method = 'loess', formula = 'y~x')+
labs(title="Calories vs. Average Total Intensity")
From the Calories vs. Average Total Intensity graph, it can be inferred that the participants who do high intensity workouts burn more calories.
ggplot(data = new_combined_data, mapping = aes(x = TimeToSleep, y = TotalSteps))+geom_smooth(method='loess', formula = 'y~x')+
xlim(0,100)+
labs(title="Total Steps vs. Time to Sleep")
The above graph show that the participants who walk or run more distance
tend to sleep faster i.e. the time they spend on bed without sleeping is
less.
int_new <- activity_data %>%
group_by(activity_data$Id) %>%
drop_na() %>%
summarise(mean_total_steps = mean(TotalSteps),
mean_total_distance = mean(TotalDistance),
mean_calories = mean(Calories))
ggplot(data = int_new, mapping = aes(x = mean_total_distance, y = mean_calories))+
geom_smooth(method = 'loess', formula = 'y~x')+
labs(title="Calories vs. Total Distance (AVERAGE)")
The graph Calories vs. Total Distance (AVERAGE) shows that participants who walk, burn more calories.
int_new <- intensity_data %>%
group_by(time) %>%
drop_na() %>%
summarise(mean_total_int = mean(TotalIntensity))
ggplot(data=int_new, aes(x=time, y=mean_total_int)) + geom_bar(stat = "identity", fill='lightblue')+
theme(axis.text.x = element_text(angle = 90)) +
labs(title="Average Total Intensity vs. Time")
From the above graph, we can assume that most of the participants do workout between 5PM to 7PM. So, some notifications can be sent to the users between this time to exercise.
Average participants took 30-40 mins to sleep. Therefore the company can recommend some breathing exercises or body relaxing activites to have an early and quality sleep.
The app can suggest some high intensity workouts to burn more calories for those users who opt to lose weight.
A minimum target of 6-7 miles can be set for the users, which covers around 10,000 - 12,000 steps. The CDC(Centers for Disease Control and Prevention) recommend that most adults should aim for 10,000 steps per day. For most people, this is the equivalent of about 8 kilometers, or 5 miles.
The app can suggest users to keep a goal of completing a minimum of 8000 steps a day to get good 7Hrs of quality sleep.
An hourly notification can be sent through the app to the users from 5PM to 7PM for workouts or exercises.