Bellabeat is a high-tech manufacturing company of health-focused products for women. This project is to analyze smart device usage data to gain insights into consumer behaviour with non-Bellabeat smart devices. Aim of this analysis is to apply these key findings and insights to a specific bellabeat product and construct recommendation to influence the Bellabeat marketing strategy.
These key findings will be presented to key stakeholders, Urška Sršen, Bellabeat’s co-founder and Chief Creative Officer, Sando Mur, Mathematician and Bellabeat’s co-founder and also key members of the Bellabeat executive team and finally to the Bellabeat marketing analytics team. These findings are expected to enhance Bellabeat marketing strategies, strengthen customer engagement and provide assistance to Bellabeat to be one of the leading companies in the tech-driven wellness industry.
For this Bellabeat data analysis, the primary data source is FitBit Fitness Tracker Data (Public Domain, dataset made available through Mobius) was generated by respondents to a distributed survey via Amazon Mechanical Turk between 03.12.2016 to 05.12.2016. This Kaggle data set contains personal fitness trackers 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.
Through preliminary observation, This data set might have the following limitation to our analysis.
Dataset was generated in 2016, which is not a recent dataset to make analysis. Relying solely on historical insights has a limited value, especially in the tech-world which is a fast-changing business. This limits the ability to identify new opportunities and potential risks because, past trends which may not apply to current or future scenarios. So, this leads to inaccurate and incomplete analysis.
This dataset contains only thirty Fitbits users which is not enough to amplify the detection of statistical differences.
Bellabeat only focuses on building high-tech smart devices to check women’s health but Fitbit data does not contain demographic data such as gender and age. When finding key trends and insights from the Fitbit dataset, we cannot interpret insights related to women accurately and also we cannot give accurate recommendations to Bellabeat.
#Load Libraries
library(tidyverse)
library(dplyr)
library(janitor)
library(skimr)
library(lubridate)
library(ggplot2)
library(knitr)
library(highcharter)
library(kableExtra)
3.1 Load dataset into R
dailyActivity <- read_csv("dailyActivity_merged.csv")
hourlyCalories <- read_csv("hourlyCalories_merged.csv")
dailySleep <- read_csv("sleepDay_merged.csv")
weightLog <- read_csv("weightLogInfo_merged.csv")
hourly_steps <- read_csv("hourlySteps_merged.csv")
3.2 Overview and structure of the above datasets
| Id | ActivityDate | TotalSteps | TotalDistance | TrackerDistance | LoggedActivitiesDistance | VeryActiveDistance | ModeratelyActiveDistance | LightActiveDistance | SedentaryActiveDistance | VeryActiveMinutes | FairlyActiveMinutes | LightlyActiveMinutes | SedentaryMinutes | Calories |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1503960366 | 4/12/2016 | 13162 | 8.50 | 8.50 | 0 | 1.88 | 0.55 | 6.06 | 0 | 25 | 13 | 328 | 728 | 1985 |
| 1503960366 | 4/13/2016 | 10735 | 6.97 | 6.97 | 0 | 1.57 | 0.69 | 4.71 | 0 | 21 | 19 | 217 | 776 | 1797 |
| 1503960366 | 4/14/2016 | 10460 | 6.74 | 6.74 | 0 | 2.44 | 0.40 | 3.91 | 0 | 30 | 11 | 181 | 1218 | 1776 |
| 1503960366 | 4/15/2016 | 9762 | 6.28 | 6.28 | 0 | 2.14 | 1.26 | 2.83 | 0 | 29 | 34 | 209 | 726 | 1745 |
| 1503960366 | 4/16/2016 | 12669 | 8.16 | 8.16 | 0 | 2.71 | 0.41 | 5.04 | 0 | 36 | 10 | 221 | 773 | 1863 |
| Id | ActivityHour | Calories |
|---|---|---|
| 1503960366 | 4/12/2016 12:00:00 AM | 81 |
| 1503960366 | 4/12/2016 1:00:00 AM | 61 |
| 1503960366 | 4/12/2016 2:00:00 AM | 59 |
| 1503960366 | 4/12/2016 3:00:00 AM | 47 |
| 1503960366 | 4/12/2016 4:00:00 AM | 48 |
| Id | SleepDay | TotalSleepRecords | TotalMinutesAsleep | TotalTimeInBed |
|---|---|---|---|---|
| 1503960366 | 4/12/2016 12:00:00 AM | 1 | 327 | 346 |
| 1503960366 | 4/13/2016 12:00:00 AM | 2 | 384 | 407 |
| 1503960366 | 4/15/2016 12:00:00 AM | 1 | 412 | 442 |
| 1503960366 | 4/16/2016 12:00:00 AM | 2 | 340 | 367 |
| 1503960366 | 4/17/2016 12:00:00 AM | 1 | 700 | 712 |
| Id | Date | WeightKg | WeightPounds | Fat | BMI | IsManualReport | LogId |
|---|---|---|---|---|---|---|---|
| 1503960366 | 5/2/2016 11:59:59 PM | 52.6 | 115.9631 | 22 | 22.65 | TRUE | 1.462234e+12 |
| 1503960366 | 5/3/2016 11:59:59 PM | 52.6 | 115.9631 | NA | 22.65 | TRUE | 1.462320e+12 |
| 1927972279 | 4/13/2016 1:08:52 AM | 133.5 | 294.3171 | NA | 47.54 | FALSE | 1.460510e+12 |
| 2873212765 | 4/21/2016 11:59:59 PM | 56.7 | 125.0021 | NA | 21.45 | TRUE | 1.461283e+12 |
| 2873212765 | 5/12/2016 11:59:59 PM | 57.3 | 126.3249 | NA | 21.69 | TRUE | 1.463098e+12 |
# strcuture of daily activity dataset
str(dailyActivity)
## 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 ...
## $ ActivityDate : chr [1:940] "4/12/2016" "4/13/2016" "4/14/2016" "4/15/2016" ...
## $ TotalSteps : num [1:940] 13162 10735 10460 9762 12669 ...
## $ TotalDistance : num [1:940] 8.5 6.97 6.74 6.28 8.16 ...
## $ TrackerDistance : num [1:940] 8.5 6.97 6.74 6.28 8.16 ...
## $ LoggedActivitiesDistance: num [1:940] 0 0 0 0 0 0 0 0 0 0 ...
## $ VeryActiveDistance : num [1:940] 1.88 1.57 2.44 2.14 2.71 ...
## $ ModeratelyActiveDistance: num [1:940] 0.55 0.69 0.4 1.26 0.41 ...
## $ LightActiveDistance : num [1:940] 6.06 4.71 3.91 2.83 5.04 ...
## $ SedentaryActiveDistance : num [1:940] 0 0 0 0 0 0 0 0 0 0 ...
## $ VeryActiveMinutes : num [1:940] 25 21 30 29 36 38 42 50 28 19 ...
## $ FairlyActiveMinutes : num [1:940] 13 19 11 34 10 20 16 31 12 8 ...
## $ LightlyActiveMinutes : num [1:940] 328 217 181 209 221 164 233 264 205 211 ...
## $ SedentaryMinutes : 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>
3.3 Data Cleaning
3.3.1 Check missing values in all the datasets
All_missing_values <- data.frame(dataset = c("dailyActivity","hourlyCalories","dailySleep","weightLog"),
missing_vlaues=c(sum(is.na(dailyActivity)),sum(is.na(hourlyCalories)),sum(is.na(dailySleep)),sum(is.na(weightLog))))
kable(All_missing_values,caption = "Count missing values in every table")
| dataset | missing_vlaues |
|---|---|
| dailyActivity | 0 |
| hourlyCalories | 0 |
| dailySleep | 0 |
| weightLog | 65 |
#selecting data without missing values from weightLog dataset.
weightLog <- select(weightLog,-"Fat")
kable(weightLog[1:5,], caption = "weightLog clean data")
| Id | Date | WeightKg | WeightPounds | BMI | IsManualReport | LogId |
|---|---|---|---|---|---|---|
| 1503960366 | 5/2/2016 11:59:59 PM | 52.6 | 115.9631 | 22.65 | TRUE | 1.462234e+12 |
| 1503960366 | 5/3/2016 11:59:59 PM | 52.6 | 115.9631 | 22.65 | TRUE | 1.462320e+12 |
| 1927972279 | 4/13/2016 1:08:52 AM | 133.5 | 294.3171 | 47.54 | FALSE | 1.460510e+12 |
| 2873212765 | 4/21/2016 11:59:59 PM | 56.7 | 125.0021 | 21.45 | TRUE | 1.461283e+12 |
| 2873212765 | 5/12/2016 11:59:59 PM | 57.3 | 126.3249 | 21.69 | TRUE | 1.463098e+12 |
#missing values in weightLog_clean
sum(is.na(weightLog))
## [1] 0
3.3.2 Check duplictaes in all datasets
sum(duplicated(dailyActivity))
## [1] 0
sum(duplicated(hourlyCalories))
## [1] 0
sum(duplicated(dailySleep))
## [1] 3
sum(duplicated(weightLog))
## [1] 0
dailySleep_clean <- distinct(dailySleep)
#checking duplictes again
sum(duplicated(dailySleep_clean))
## [1] 0
3.3.3 Convert date formats in every dataset
dailyActivity <- dailyActivity %>%
rename(Date = ActivityDate) %>%
mutate(Date = as.Date(Date, format = "%m/%d/%y"))
dailySleep_clean <- dailySleep_clean %>%
rename(Date = SleepDay) %>%
mutate(Date = as.Date(Date, format = "%m/%d/%y"))
weightLog <- weightLog %>%
select(-LogId) %>%
mutate(Date = as.Date(Date, format = "%m/%d/%y")) %>%
mutate(IsManualReport = as.factor(IsManualReport))
After converting date columns.
kable(dailyActivity[1:5,1:5])
| Id | Date | TotalSteps | TotalDistance | TrackerDistance |
|---|---|---|---|---|
| 1503960366 | 2020-04-12 | 13162 | 8.50 | 8.50 |
| 1503960366 | 2020-04-13 | 10735 | 6.97 | 6.97 |
| 1503960366 | 2020-04-14 | 10460 | 6.74 | 6.74 |
| 1503960366 | 2020-04-15 | 9762 | 6.28 | 6.28 |
| 1503960366 | 2020-04-16 | 12669 | 8.16 | 8.16 |
kable(dailySleep_clean[1:5,])
| Id | Date | TotalSleepRecords | TotalMinutesAsleep | TotalTimeInBed |
|---|---|---|---|---|
| 1503960366 | 2020-04-12 | 1 | 327 | 346 |
| 1503960366 | 2020-04-13 | 2 | 384 | 407 |
| 1503960366 | 2020-04-15 | 1 | 412 | 442 |
| 1503960366 | 2020-04-16 | 2 | 340 | 367 |
| 1503960366 | 2020-04-17 | 1 | 700 | 712 |
kable(weightLog[1:5,])
| Id | Date | WeightKg | WeightPounds | BMI | IsManualReport |
|---|---|---|---|---|---|
| 1503960366 | 2020-05-02 | 52.6 | 115.9631 | 22.65 | TRUE |
| 1503960366 | 2020-05-03 | 52.6 | 115.9631 | 22.65 | TRUE |
| 1927972279 | 2020-04-13 | 133.5 | 294.3171 | 47.54 | FALSE |
| 2873212765 | 2020-04-21 | 56.7 | 125.0021 | 21.45 | TRUE |
| 2873212765 | 2020-05-12 | 57.3 | 126.3249 | 21.69 | TRUE |
3.4 Summary of each datasets
# Summarize selected columns in daily_activity dataset
dailyActivity %>% select(TotalSteps,
TotalDistance,
Calories,
SedentaryMinutes,
LightlyActiveMinutes,
FairlyActiveMinutes,
VeryActiveMinutes) %>% skim_without_charts()
| Name | Piped data |
| Number of rows | 940 |
| Number of columns | 7 |
| _______________________ | |
| Column type frequency: | |
| numeric | 7 |
| ________________________ | |
| Group variables | None |
Variable type: numeric
| skim_variable | n_missing | complete_rate | mean | sd | p0 | p25 | p50 | p75 | p100 |
|---|---|---|---|---|---|---|---|---|---|
| TotalSteps | 0 | 1 | 7637.91 | 5087.15 | 0 | 3789.75 | 7405.50 | 10727.00 | 36019.00 |
| TotalDistance | 0 | 1 | 5.49 | 3.92 | 0 | 2.62 | 5.24 | 7.71 | 28.03 |
| Calories | 0 | 1 | 2303.61 | 718.17 | 0 | 1828.50 | 2134.00 | 2793.25 | 4900.00 |
| SedentaryMinutes | 0 | 1 | 991.21 | 301.27 | 0 | 729.75 | 1057.50 | 1229.50 | 1440.00 |
| LightlyActiveMinutes | 0 | 1 | 192.81 | 109.17 | 0 | 127.00 | 199.00 | 264.00 | 518.00 |
| FairlyActiveMinutes | 0 | 1 | 13.56 | 19.99 | 0 | 0.00 | 6.00 | 19.00 | 143.00 |
| VeryActiveMinutes | 0 | 1 | 21.16 | 32.84 | 0 | 0.00 | 4.00 | 32.00 | 210.00 |
# Summarize selected columns in weightLog_clean dataset
weightLog %>% select(WeightKg,BMI) %>% skim_without_charts()
| Name | Piped data |
| Number of rows | 67 |
| Number of columns | 2 |
| _______________________ | |
| Column type frequency: | |
| numeric | 2 |
| ________________________ | |
| Group variables | None |
Variable type: numeric
| skim_variable | n_missing | complete_rate | mean | sd | p0 | p25 | p50 | p75 | p100 |
|---|---|---|---|---|---|---|---|---|---|
| WeightKg | 0 | 1 | 72.04 | 13.92 | 52.60 | 61.40 | 62.50 | 85.05 | 133.50 |
| BMI | 0 | 1 | 25.19 | 3.07 | 21.45 | 23.96 | 24.39 | 25.56 | 47.54 |
# Summarize selected columns in dailySleep_clean dataset
dailySleep_clean %>% select(TotalSleepRecords,
TotalMinutesAsleep,
TotalTimeInBed) %>% skim_without_charts()
| Name | Piped data |
| Number of rows | 410 |
| Number of columns | 3 |
| _______________________ | |
| Column type frequency: | |
| numeric | 3 |
| ________________________ | |
| Group variables | None |
Variable type: numeric
| skim_variable | n_missing | complete_rate | mean | sd | p0 | p25 | p50 | p75 | p100 |
|---|---|---|---|---|---|---|---|---|---|
| TotalSleepRecords | 0 | 1 | 1.12 | 0.35 | 1 | 1.00 | 1.0 | 1 | 3 |
| TotalMinutesAsleep | 0 | 1 | 419.17 | 118.64 | 58 | 361.00 | 432.5 | 490 | 796 |
| TotalTimeInBed | 0 | 1 | 458.48 | 127.46 | 61 | 403.75 | 463.0 | 526 | 961 |
Key Findings
Activity Data (dailyActivity)
From this dataset we can clearly see average number of steps per day is 7638. Moreover, maximum number of steps per day is 36019 and median of 7406 steps per day.
The Average Calories burning per day is 2304 and with a maximum of 4900. According to WebMD,Calories burning process depends on age,sex,height,weight and the daily exercising routine. The average adult woman burns 1600-1950 calories and the average adult male burns 2000-2500 calories per day naturally. So, this indicates some users have calorie burning far above the average levels.
Sedentary minutes indicates diverse activities and lifestyle habits which has an average of 991 minutes per day with a maximum of 1440 minutes.
Total distance vary from 0km to 28km per day with an average of 5.49km.
Lightly active minutes and very active minutes have an average of 192.81 and 21.16 minutes per day respectively. This shows most users have lower active days.
Weight Data (weightLog_clean)
The average weight of an user is 72.04kg. Lowest and maximum weight of users are 52.6kg and 133.5kg respectively.
The average BMI is 25.19, indicating that users, on average, fall within the overweight category based on NSW Health.
Sleep Data (dailySleep_clean)
Below data frame shows how users have participated in each dataset. There are only eight users in weightLog dataset while dailyActivity dataset has 33 users. So weightLog dataset is imbalance compare to dailyActivity.
#checking number of user
user_count <- data.frame(dataset=c("dailyActivity","dailySleep_clean","weightLog_clean"),
number_of_users=c(n_distinct(dailyActivity$Id),n_distinct(dailySleep_clean$Id),n_distinct(weightLog$Id)))
kable(user_count)
| dataset | number_of_users |
|---|---|
| dailyActivity | 33 |
| dailySleep_clean | 24 |
| weightLog_clean | 8 |
3.5 Merging the dataframes
df <- merge(dailyActivity,dailySleep_clean,by = c ("Id", "Date"))
final_df <- merge(df,weightLog,by = c ("Id", "Date"))
glimpse(final_df)
## Rows: 35
## Columns: 22
## $ Id <dbl> 1503960366, 1503960366, 1927972279, 455860992…
## $ Date <date> 2020-05-02, 2020-05-03, 2020-04-13, 2020-05-…
## $ TotalSteps <dbl> 14727, 15103, 356, 3428, 12231, 10199, 5652, …
## $ TotalDistance <dbl> 9.71, 9.66, 0.25, 2.27, 9.14, 6.74, 3.74, 1.0…
## $ TrackerDistance <dbl> 9.71, 9.66, 0.25, 2.27, 9.14, 6.74, 3.74, 1.0…
## $ LoggedActivitiesDistance <dbl> 0.000000, 0.000000, 0.000000, 0.000000, 0.000…
## $ VeryActiveDistance <dbl> 3.21, 3.73, 0.00, 0.00, 5.98, 3.40, 0.57, 0.0…
## $ ModeratelyActiveDistance <dbl> 0.57, 1.05, 0.00, 0.00, 0.83, 0.83, 1.21, 0.0…
## $ LightActiveDistance <dbl> 5.92, 4.88, 0.25, 2.27, 2.32, 2.51, 1.96, 1.0…
## $ SedentaryActiveDistance <dbl> 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.0…
## $ VeryActiveMinutes <dbl> 41, 50, 0, 0, 200, 50, 8, 0, 0, 50, 5, 13, 35…
## $ FairlyActiveMinutes <dbl> 15, 24, 0, 0, 37, 14, 24, 0, 0, 3, 13, 42, 41…
## $ LightlyActiveMinutes <dbl> 277, 254, 32, 190, 159, 189, 142, 86, 217, 28…
## $ SedentaryMinutes <dbl> 798, 816, 986, 1121, 525, 796, 548, 862, 837,…
## $ Calories <dbl> 2004, 1990, 2151, 1692, 4552, 1994, 1718, 146…
## $ TotalSleepRecords <dbl> 1, 1, 1, 1, 1, 1, 3, 2, 1, 1, 1, 1, 1, 1, 1, …
## $ TotalMinutesAsleep <dbl> 277, 273, 398, 115, 549, 366, 630, 508, 370, …
## $ TotalTimeInBed <dbl> 309, 296, 422, 129, 583, 387, 679, 535, 386, …
## $ WeightKg <dbl> 52.6, 52.6, 133.5, 69.9, 90.7, 62.5, 62.1, 61…
## $ WeightPounds <dbl> 115.9631, 115.9631, 294.3171, 154.1031, 199.9…
## $ BMI <dbl> 22.65, 22.65, 47.54, 27.32, 28.00, 24.39, 24.…
## $ IsManualReport <fct> TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, T…
4.1 Calculating correlation coefficients
1.Total steps vs Calories
#Totalsteps vs calories
ggplot(dailyActivity,aes(x=TotalSteps,y=Calories,color=Calories))+geom_point() + geom_smooth(method = "loess")+labs(title = "Total Steps vs Calories")+custome_theme() +theme(legend.position = c(.8,.3),plot.title = element_text(hjust = 0.5))
Calculating correlation coefficient between total steps and calories
cor(dailyActivity$TotalSteps,dailyActivity$Calories)
## [1] 0.5915681
The correlation coefficient between Total Steps and Calories is 0.59. It shows positive correlation. This correlation clearly shows, when number of steps increases, amount of calories burn tend to increase. So, users who take more steps might burn more calories. This correlation clearly visualize in the above scatter plot.
2.Total distance vs Calories
ggplot(dailyActivity,aes(x=TotalDistance,y=Calories,colour =Calories))+geom_point() + geom_smooth(method = "loess")+labs(title = "Total Distance vs Calories")+custome_theme() +theme(legend.position = c(.8,.3),plot.title = element_text(hjust = 0.5)) + scale_colour_gradient(low = "darkgreen", high = "darkolivegreen1")
Calculating correlation coefficient between total distance and calories
cor(dailyActivity$TotalDistance,dailyActivity$Calories)
## [1] 0.6449619
The correlation coefficient between Total Distance and Calories is 0.64 and shows strong positive correlation. It suggests that there is a significant relationship between the total distance and the calories. Users who cover more distance tend to burn more calories.
Both scatter plots supports the idea of higher physical activities, clearly helps to burn more calories. It emphasizes the importance of consistent physical activity in improving overall health and fitness.
4.2 Distribution of daily activity level
activity <- dailyActivity %>% select(VeryActiveMinutes,
FairlyActiveMinutes,
LightlyActiveMinutes,
SedentaryMinutes)%>%
summarise(across(everything(),list(sum))) %>%
gather(active_level,minutes) %>%
mutate(active_level=factor(active_level,labels=c("Moderate Activity","Light Activity",
"Sedentary","Heavy Activity")))
activity %>% hchart('pie',hcaes(x=active_level,y=minutes)) %>%
hc_title(text = "Distribution of daily activity level in minutes",
align = "center") %>%
hc_tooltip(pointFormat =" <b> Value:</b> {point.y} <br>
<b>Percentage</b> {point.percentage:,.2f}%")
Above graph shows mojority of the day people are sedentary.
4.3 Hourly Average Calories Expenditure
hh <- hourlyCalories %>% rename(date_time=ActivityHour) %>% separate(date_time,into=c("date","time"),sep = "^\\S*\\K\\s+")
hh$date <- as.Date(hh$date, format = "%m/%d/%Y")
hh$time <- format(strptime(hh$time,"%I:%M:%S %p"), format ="%H:%M:%S" )
kable(hh[1:5,])
| Id | date | time | Calories |
|---|---|---|---|
| 1503960366 | 2016-04-12 | 00:00:00 | 81 |
| 1503960366 | 2016-04-12 | 01:00:00 | 61 |
| 1503960366 | 2016-04-12 | 02:00:00 | 59 |
| 1503960366 | 2016-04-12 | 03:00:00 | 47 |
| 1503960366 | 2016-04-12 | 04:00:00 | 48 |
hh %>%
group_by(time) %>%
summarize(average_cal=mean(Calories)) %>%
ggplot()+
geom_col(mapping=aes(x=time,y=average_cal,fill=average_cal))+
labs(title="Hourly Average Calories vs hour of day",x="hours",y="average calories per hour")+
scale_fill_gradient(low="pink",high="purple")+
theme(axis.text.x=element_text(angle=90),plot.title = element_text(hjust = 0.5))
The highest calories expenditure recorded in the evening between 5:00 p.m to 7:00 p.m.
4.4 Hourly Average Steps
hourly_steps<- hourly_steps %>% rename(date_time=ActivityHour) %>% separate(date_time,into=c("date","time"),sep = "^\\S*\\K\\s+")
hourly_steps$date <- as.Date(hourly_steps$date, format = "%m/%d/%Y")
hourly_steps$time <- format(strptime(hourly_steps$time,"%I:%M:%S %p"), format ="%H:%M:%S" )
kable(hourly_steps[1:5,])
| Id | date | time | StepTotal |
|---|---|---|---|
| 1503960366 | 2016-04-12 | 00:00:00 | 373 |
| 1503960366 | 2016-04-12 | 01:00:00 | 160 |
| 1503960366 | 2016-04-12 | 02:00:00 | 151 |
| 1503960366 | 2016-04-12 | 03:00:00 | 0 |
| 1503960366 | 2016-04-12 | 04:00:00 | 0 |
hourly_steps %>%
group_by(time) %>%
summarize(average_steps=mean(StepTotal)) %>%
ggplot()+
geom_col(mapping=aes(x=time,y=average_steps,fill=average_steps))+
labs(title="Hourly Average Steps vs hour of day",x="hours",y="average steps per hour")+
scale_fill_gradient(low="limegreen",high="darkolivegreen")+
theme(axis.text.x=element_text(angle=90),plot.title = element_text(hjust = 0.5))
As above graph shows, the users are the most active from 8:00 a.m. to 7:00 p.m. and number of steps are increased in the evening between 5:00 p.m. to 7:00 p.m. but peaking at 6:00 p.m.
4.5 Sleep Distibution
sleep <- dailySleep %>%
select(TotalMinutesAsleep) %>%
drop_na() %>%
mutate(sleep_quality=ifelse(TotalMinutesAsleep<=420, "Less than 7h",
ifelse(TotalMinutesAsleep <= 540, "7h to 9h",
"More than 9h"))) %>%
mutate(sleep_quality = factor(sleep_quality, levels = c("Less than 7h","7h to 9h","More than 9h")))
sleep %>% ggplot(aes(x=TotalMinutesAsleep,fill = sleep_quality))+geom_histogram(position = "dodge",bins = 30)+custome_theme() + labs(title = "Sleep distribution") + theme(plot.title = element_text(hjust = 0.5))
In this graph clearly shows most of the user’s get average of 5 to 8 hours of sleep.
Recommendations for Bellabeat products-
Activity Goal Reminders - Let users to set daily goals, weekly goals or monthly goals and remind them daily what task has to be done to achieve their goals. Moreover, show their progress step by step, then users could get an idea of what they achieve in meantime. Then, additionally introduce a ranking system among users who’s doing better at their tasks.
Introduce Specific Workout Routine - Introducing High-intensity workout programs, weightlifting programs and sports to maintain their active life. This will improve their steps and time spending sedentary activities.
Introduce Meal Preparations - New meal plans to avoid junk food and consume good quality food to stay healthy.
Recommend Quality Sleep - Send tips how to improve sleep time.