Bellabeat is a high-tech manufacturer of health focused products tailored to women. Although they are a successful small company, they are seeking to unleash the potential of becoming a larger player in the global smart device market.The analysis will be focused on evaluating data from smart devices to explore opportunities that could support this expansion for growth.
Bellabeat is a women’s wellness company that manufactures health-focused smart products.They have launched multiple products that gather information on activity, sleep, stress, and reproductive health. Their mission is to empower women with knowledge about their own health and habits.
The dataset used for this analysis is the . This dataset contains personal
fitness tracker information from users and includes daily activity,
steps, heart rate, sleep and minute-level output for physical
activity.
Gain insight into the utilization trends of smart devices, and how the determined trends be relevant to Bellabeat customers and influence the companys’ marketing strategy.
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.0
## ✔ ggplot2 3.4.2 ✔ 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(ggplot2)
library(here)
## here() starts at /cloud/project
library(skimr)
library(janitor)
##
## Attaching package: 'janitor'
##
## The following objects are masked from 'package:stats':
##
## chisq.test, fisher.test
library(rmarkdown)
library(lubridate)
library(readxl)
library(dplyr)
activities <- read.csv("Fitabase Data 4.12.16-5.12.16/dailyActivity_merged.csv")
calories <- read.csv("Fitabase Data 4.12.16-5.12.16/dailyCalories_merged.csv")
steps <- read.csv("Fitabase Data 4.12.16-5.12.16/dailySteps_merged.csv")
sleep <- read.csv("Fitabase Data 4.12.16-5.12.16/sleepDay_merged.csv")
weight <- read.csv("Fitabase Data 4.12.16-5.12.16/weightLogInfo_merged.csv")
intensities <- read.csv("Fitabase Data 4.12.16-5.12.16/dailyIntensities_merged.csv")
The provided code showcases a preview of the selected data frames using the head() function.
head(activities)
## 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(sleep)
## 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(intensities)
## Id ActivityDay SedentaryMinutes LightlyActiveMinutes
## 1 1503960366 4/12/2016 728 328
## 2 1503960366 4/13/2016 776 217
## 3 1503960366 4/14/2016 1218 181
## 4 1503960366 4/15/2016 726 209
## 5 1503960366 4/16/2016 773 221
## 6 1503960366 4/17/2016 539 164
## FairlyActiveMinutes VeryActiveMinutes SedentaryActiveDistance
## 1 13 25 0
## 2 19 21 0
## 3 11 30 0
## 4 34 29 0
## 5 10 36 0
## 6 20 38 0
## LightActiveDistance ModeratelyActiveDistance VeryActiveDistance
## 1 6.06 0.55 1.88
## 2 4.71 0.69 1.57
## 3 3.91 0.40 2.44
## 4 2.83 1.26 2.14
## 5 5.04 0.41 2.71
## 6 2.51 0.78 3.19
Identifying all columns of each dataset.
colnames(activities)
## [1] "Id" "ActivityDate"
## [3] "TotalSteps" "TotalDistance"
## [5] "TrackerDistance" "LoggedActivitiesDistance"
## [7] "VeryActiveDistance" "ModeratelyActiveDistance"
## [9] "LightActiveDistance" "SedentaryActiveDistance"
## [11] "VeryActiveMinutes" "FairlyActiveMinutes"
## [13] "LightlyActiveMinutes" "SedentaryMinutes"
## [15] "Calories"
colnames(sleep)
## [1] "Id" "SleepDay" "TotalSleepRecords"
## [4] "TotalMinutesAsleep" "TotalTimeInBed"
colnames(intensities)
## [1] "Id" "ActivityDay"
## [3] "SedentaryMinutes" "LightlyActiveMinutes"
## [5] "FairlyActiveMinutes" "VeryActiveMinutes"
## [7] "SedentaryActiveDistance" "LightActiveDistance"
## [9] "ModeratelyActiveDistance" "VeryActiveDistance"
Noted ‘Id’ field on each dataset. Merging the datasets:
# merge two dataframes by ID total <- merge(activities, sleep, intensities)
The subsequent set of code will provide information regarding the count of participants in each dataset.
n_distinct(activities$Id)
## [1] 33
n_distinct(sleep$Id)
## [1] 24
n_distinct(intensities$Id)
## [1] 33
A count of 33 participants is observed across activities and intesities and a 24 count of participants in the sleep dataset.
We will proceed to identify and address any duplicate entries within the datasets.
sum(duplicated(activities))
## [1] 0
sum(duplicated(sleep))
## [1] 3
sum(duplicated(intensities))
## [1] 0
Removing duplicate entries for sleep dataset.
sleep <- sleep %>%
distinct()
Next, we will rename and format specific columns to merge data.
activities <- activities %>%
rename(date=ActivityDate) %>%
mutate(date=as_date(date, format="%m/%d/%Y"))
sleep <- sleep %>%
rename(date= SleepDay) %>%
mutate(date=as_date(date, format="%m/%d/%Y %I:%M:%S %p" , tz=Sys.timezone()))
## Warning: There was 1 warning in `mutate()`.
## ℹ In argument: `date = as_date(date, format = "%m/%d/%Y %I:%M:%S %p", tz =
## Sys.timezone())`.
## Caused by warning:
## ! `tz` argument is ignored by `as_date()`
Some quick summary statistics about each data frame.
#For the daily activity dataframe:
activities %>%
select(TotalSteps, TotalDistance, SedentaryMinutes, Calories) %>%
summary()
## TotalSteps TotalDistance SedentaryMinutes Calories
## Min. : 0 Min. : 0.000 Min. : 0.0 Min. : 0
## 1st Qu.: 3790 1st Qu.: 2.620 1st Qu.: 729.8 1st Qu.:1828
## Median : 7406 Median : 5.245 Median :1057.5 Median :2134
## Mean : 7638 Mean : 5.490 Mean : 991.2 Mean :2304
## 3rd Qu.:10727 3rd Qu.: 7.713 3rd Qu.:1229.5 3rd Qu.:2793
## Max. :36019 Max. :28.030 Max. :1440.0 Max. :4900
#For sleep
sleep %>%
select(TotalSleepRecords, TotalMinutesAsleep, TotalTimeInBed) %>%
summary()
## TotalSleepRecords TotalMinutesAsleep TotalTimeInBed
## 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
Insights derived from summary statistics:
-On average, an individual sleeps once a day for a duration of 419.5 minutes, which is approximately equivelent to 7 hours. -The mean durations for very active and fairly active minutes per individual are 21.16 and 13.56 minutes, respectively. - The number of users that have Total steps of 7500 and above (which is classified as Active and somewhat active users) is quite low while a lot of users have Total steps below 7500, indicating that even those with low step counts are regularly recording steps with smart devices turned on.
Inner Join column “Id”.
merged_data <- merge(sleep, activities, by="Id")
head(merged_data)
## Id date.x TotalSleepRecords TotalMinutesAsleep TotalTimeInBed
## 1 1503960366 2016-04-12 1 327 346
## 2 1503960366 2016-04-12 1 327 346
## 3 1503960366 2016-04-12 1 327 346
## 4 1503960366 2016-04-12 1 327 346
## 5 1503960366 2016-04-12 1 327 346
## 6 1503960366 2016-04-12 1 327 346
## date.y TotalSteps TotalDistance TrackerDistance LoggedActivitiesDistance
## 1 2016-05-07 11992 7.71 7.71 0
## 2 2016-05-06 12159 8.03 8.03 0
## 3 2016-05-01 10602 6.81 6.81 0
## 4 2016-04-30 14673 9.25 9.25 0
## 5 2016-04-12 13162 8.50 8.50 0
## 6 2016-04-13 10735 6.97 6.97 0
## VeryActiveDistance ModeratelyActiveDistance LightActiveDistance
## 1 2.46 2.12 3.13
## 2 1.97 0.25 5.81
## 3 2.29 1.60 2.92
## 4 3.56 1.42 4.27
## 5 1.88 0.55 6.06
## 6 1.57 0.69 4.71
## SedentaryActiveDistance VeryActiveMinutes FairlyActiveMinutes
## 1 0 37 46
## 2 0 24 6
## 3 0 33 35
## 4 0 52 34
## 5 0 25 13
## 6 0 21 19
## LightlyActiveMinutes SedentaryMinutes Calories
## 1 175 833 1821
## 2 289 754 1896
## 3 246 730 1820
## 4 217 712 1947
## 5 328 728 1985
## 6 217 776 1797
ggplot(data=activities, aes(x=TotalSteps, y=SedentaryMinutes)) + geom_point()
The plot distinctly illustrates a positive correlation between the daily step count and the corresponding calorie expenditure.
ggplot(data=sleep, aes(x=TotalMinutesAsleep, y=TotalTimeInBed))+ geom_point()
The correlation between the total time spent in bed and the total time asleep exhibits a linear pattern.