Introduction to Bellabeat Tech Company

Data Sources used for Analysis

FitBit Fitness Tracker Data, a public dataset on Kaggle made available through Mobius. This Kaggle data set contains personal fitness tracker from thirty Fitbit users who 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.

Summary, Key Findings and Recommendations

From the dataset, I found that the average person walks 6,546 steps, 4.7km distance and burns 2189 calories daily.

I also discovered that the average hours for sleep was 3 although the data provided for this makes the results seem a bit inconclusive because as a result of insufficient data.

The average weight by individuals was 73kg and the average heartrate, 80pm.

I recommend that clients should be encouraged more to sleep and make sure the records are entered on the devices to enable data accuracy. Bellabeat can promote ads which inform clients to make proper use of their devices.

Although the average heartrate was healthy, the maximum showed that some users have unhealthy heartrates which should be checked to prevent health complications.

These are the factors that Bellabeat should consider while creating or modifying their fitness tracker device as it gives them an edge over competitors and an opprotunity to do better.

Step 1: Install tidyverse packages

The first thing I did before I began my analysis was to install the tidyverse packages which enabled me run my analysis in R seamlessly.

install.packages("tidyverse")
## Installing package into '/cloud/lib/x86_64-pc-linux-gnu-library/4.4'
## (as 'lib' is unspecified)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.5.1     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.1
## ✔ 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(janitor)
## 
## Attaching package: 'janitor'
## 
## The following objects are masked from 'package:stats':
## 
##     chisq.test, fisher.test
library(skimr)

Step 2: Import the dataset.

Next, I imported the dataset which I needed for the analysis to begin the process of cleaning the data.

bellabeat_activity <- read.csv("/cloud/project/mturkfitbit_export_3.12.16-4.11.16/Fitabase Data 3.12.16-4.11.16/dailyActivity_merged.csv")
bellabeat_heartrate <- read_csv("/cloud/project/mturkfitbit_export_3.12.16-4.11.16/Fitabase Data 3.12.16-4.11.16/heartrate_seconds_merged.csv")
## Rows: 1154681 Columns: 3
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): Time
## dbl (2): Id, Value
## 
## ℹ 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.
bellabeat_calories <- read.csv("/cloud/project/mturkfitbit_export_3.12.16-4.11.16/Fitabase Data 3.12.16-4.11.16/hourlyCalories_merged.csv")
bellabeat_steps <- read.csv("/cloud/project/mturkfitbit_export_3.12.16-4.11.16/Fitabase Data 3.12.16-4.11.16/hourlySteps_merged.csv")
bellabeat_sleep <- read.csv("/cloud/project/mturkfitbit_export_3.12.16-4.11.16/Fitabase Data 3.12.16-4.11.16/minuteSleep_merged.csv")
bellabeat_weight <- read.csv("/cloud/project/mturkfitbit_export_3.12.16-4.11.16/Fitabase Data 3.12.16-4.11.16/weightLogInfo_merged.csv")

Step 3: View the data to understand it.

This was done using the head function

head(bellabeat_activity)
head(bellabeat_calories)
head(bellabeat_heartrate)
head(bellabeat_sleep)
head(bellabeat_steps)
head(bellabeat_weight)

Step 3: Clean the data

I carried this out by using the skimr and lubridate(to align the date formats in each table) packages.

bellabeat_sleep$date=as.POSIXct(bellabeat_sleep$date, format="%m/%d/%Y %I:%M:%S %p", tz=Sys.timezone())
bellabeat_sleep$date <- format(bellabeat_sleep$date, format = "%m/%d/%y")
bellabeat_calories$ActivityHour=as.POSIXct(bellabeat_calories$ActivityHour, format="%m/%d/%Y %I:%M:%S %p", tz=Sys.timezone())
bellabeat_calories$ActivityHour <- format(bellabeat_calories$ActivityHour, format = "%m/%d/%y")
bellabeat_heartrate$Time=as.POSIXct(bellabeat_heartrate$Time, format="%m/%d/%Y %I:%M:%S %p", tz=Sys.timezone())
bellabeat_heartrate$Time <- format(bellabeat_heartrate$Time, format = "%m/%d/%y")
bellabeat_steps$ActivityHour=as.POSIXct(bellabeat_steps$ActivityHour, format="%m/%d/%Y %I:%M:%S %p", tz=Sys.timezone())
bellabeat_steps$ActivityHour <- format(bellabeat_steps$ActivityHour, format = "%m/%d/%y")
bellabeat_weight$Date=as.POSIXct(bellabeat_weight$Date, format="%m/%d/%Y %I:%M:%S %p", tz=Sys.timezone())
bellabeat_weight$Date <- format(bellabeat_weight$Date, format = "%m/%d/%y")
skim(bellabeat_activity)
Data summary
Name bellabeat_activity
Number of rows 457
Number of columns 15
_______________________
Column type frequency:
character 1
numeric 14
________________________
Group variables None

Variable type: character

skim_variable n_missing complete_rate min max empty n_unique whitespace
ActivityDate 0 1 8 9 0 32 0

Variable type: numeric

skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist
Id 0 1 4.628595e+09 2.293781e+09 1503960366 2.347168e+09 4.057193e+09 6.391747e+09 8.877689e+09 ▇▇▃▅▃
TotalSteps 0 1 6.546560e+03 5.398490e+03 0 1.988000e+03 5.986000e+03 1.019800e+04 2.849700e+04 ▇▆▂▁▁
TotalDistance 0 1 4.660000e+00 4.080000e+00 0 1.410000e+00 4.090000e+00 7.160000e+00 2.753000e+01 ▇▅▁▁▁
TrackerDistance 0 1 4.610000e+00 4.070000e+00 0 1.280000e+00 4.090000e+00 7.110000e+00 2.753000e+01 ▇▅▁▁▁
LoggedActivitiesDistance 0 1 1.800000e-01 8.500000e-01 0 0.000000e+00 0.000000e+00 0.000000e+00 6.730000e+00 ▇▁▁▁▁
VeryActiveDistance 0 1 1.180000e+00 2.490000e+00 0 0.000000e+00 0.000000e+00 1.310000e+00 2.192000e+01 ▇▁▁▁▁
ModeratelyActiveDistance 0 1 4.800000e-01 8.300000e-01 0 0.000000e+00 2.000000e-02 6.700000e-01 6.400000e+00 ▇▁▁▁▁
LightActiveDistance 0 1 2.890000e+00 2.240000e+00 0 8.700000e-01 2.930000e+00 4.460000e+00 1.251000e+01 ▇▆▂▁▁
SedentaryActiveDistance 0 1 0.000000e+00 1.000000e-02 0 0.000000e+00 0.000000e+00 0.000000e+00 1.000000e-01 ▇▁▁▁▁
VeryActiveMinutes 0 1 1.662000e+01 2.892000e+01 0 0.000000e+00 0.000000e+00 2.500000e+01 2.020000e+02 ▇▁▁▁▁
FairlyActiveMinutes 0 1 1.307000e+01 3.621000e+01 0 0.000000e+00 1.000000e+00 1.600000e+01 6.600000e+02 ▇▁▁▁▁
LightlyActiveMinutes 0 1 1.700700e+02 1.222100e+02 0 6.400000e+01 1.810000e+02 2.570000e+02 7.200000e+02 ▇▇▂▁▁
SedentaryMinutes 0 1 9.952800e+02 3.370200e+02 32 7.280000e+02 1.057000e+03 1.285000e+03 1.440000e+03 ▁▂▆▅▇
Calories 0 1 2.189450e+03 8.154800e+02 0 1.776000e+03 2.062000e+03 2.667000e+03 4.562000e+03 ▁▅▇▃▁
skim(bellabeat_calories)
Data summary
Name bellabeat_calories
Number of rows 24084
Number of columns 3
_______________________
Column type frequency:
character 1
numeric 2
________________________
Group variables None

Variable type: character

skim_variable n_missing complete_rate min max empty n_unique whitespace
ActivityHour 0 1 8 8 0 32 0

Variable type: numeric

skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist
Id 0 1 4.889424e+09 2421565819.2 1503960366 2347167796 4558609924 6962181067 8877689391 ▇▅▃▅▅
Calories 0 1 9.427000e+01 59.4 42 61 77 104 933 ▇▁▁▁▁
skim(bellabeat_heartrate)
Data summary
Name bellabeat_heartrate
Number of rows 1154681
Number of columns 3
_______________________
Column type frequency:
character 1
numeric 2
________________________
Group variables None

Variable type: character

skim_variable n_missing complete_rate min max empty n_unique whitespace
Time 0 1 8 8 0 15 0

Variable type: numeric

skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist
Id 0 1 5.352122e+09 2.033584e+09 2022484408 4020332650 5553957443 6962181067 8877689391 ▅▇▆▅▃
Value 0 1 7.976000e+01 1.873000e+01 36 66 77 90 185 ▃▇▂▁▁
skim(bellabeat_sleep)
Data summary
Name bellabeat_sleep
Number of rows 198559
Number of columns 4
_______________________
Column type frequency:
character 1
numeric 3
________________________
Group variables None

Variable type: character

skim_variable n_missing complete_rate min max empty n_unique whitespace
date 0 1 8 8 0 33 0

Variable type: numeric

skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist
Id 0 1 4.824304e+09 2.173935e+09 1503960366 2347167796 4702921684 6775888955 8792009665 ▇▃▇▆▃
value 0 1 1.090000e+00 3.100000e-01 1 1 1 1 3 ▇▁▁▁▁
logId 0 1 1.124161e+10 7.969858e+07 11103653021 11165512026 11243951252 11310735495 11374876178 ▇▆▇▇▇
skim(bellabeat_steps)
Data summary
Name bellabeat_steps
Number of rows 24084
Number of columns 3
_______________________
Column type frequency:
character 1
numeric 2
________________________
Group variables None

Variable type: character

skim_variable n_missing complete_rate min max empty n_unique whitespace
ActivityHour 0 1 8 8 0 32 0

Variable type: numeric

skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist
Id 0 1 4.889424e+09 2.421566e+09 1503960366 2347167796 4558609924 6962181067 8877689391 ▇▅▃▅▅
StepTotal 0 1 2.862200e+02 6.649200e+02 0 0 10 289 10565 ▇▁▁▁▁
skim(bellabeat_weight)
Data summary
Name bellabeat_weight
Number of rows 33
Number of columns 8
_______________________
Column type frequency:
character 2
numeric 6
________________________
Group variables None

Variable type: character

skim_variable n_missing complete_rate min max empty n_unique whitespace
Date 0 1 8 8 0 14 0
IsManualReport 0 1 4 5 0 2 0

Variable type: numeric

skim_variable n_missing complete_rate mean sd p0 p25 p50 p75 p100 hist
Id 0 1.00 6.477156e+09 2.308888e+09 1.503960e+09 4.702922e+09 6.962181e+09 8.877689e+09 8.877689e+09 ▃▁▁▇▆
WeightKg 0 1.00 7.344000e+01 1.653000e+01 5.330000e+01 6.170000e+01 6.250000e+01 8.580000e+01 1.296000e+02 ▇▁▅▁▁
WeightPounds 0 1.00 1.619100e+02 3.644000e+01 1.175100e+02 1.360300e+02 1.377900e+02 1.891600e+02 2.857200e+02 ▇▁▅▁▁
Fat 31 0.06 1.600000e+01 8.490000e+00 1.000000e+01 1.300000e+01 1.600000e+01 1.900000e+01 2.200000e+01 ▇▁▁▁▇
BMI 0 1.00 2.573000e+01 4.330000e+00 2.145000e+01 2.410000e+01 2.439000e+01 2.576000e+01 4.617000e+01 ▇▁▁▁▁
LogId 0 1.00 1.459959e+12 3.088072e+08 1.459382e+12 1.459753e+12 1.459987e+12 1.460160e+12 1.460506e+12 ▅▆▇▇▆

Step 4 :Summarize the data

The data was summarized to gain insights by using some aggregate functions in the tidyverse package.

activity_summary <-
  bellabeat_activity %>% 
  summarise(average_TotalSteps=mean(TotalSteps),
            min_TotalSteps=min(TotalSteps),
            max_TotalSteps=max(TotalSteps),
            average_TotalDistance=mean(TotalDistance),
           min_TotalDistance=min(TotalDistance),
            max_TotalDistance=max(TotalDistance),
          average_Calories=mean(Calories),
           min_Calories=min(Calories),
            max_Calories=max(Calories))
head(activity_summary)
calories_summary <-
  bellabeat_calories %>% 
  summarise(average_Calories=mean(Calories),
           min_Calories=min(Calories),
            max_Calories=max(Calories))
head(calories_summary)
heartrate_summary <-
  bellabeat_heartrate %>% 
  summarise(average_heartrate=mean(Value),
           min_heartrate=min(Value),
            max_heartrate=max(Value))
head(heartrate_summary)
weight_summary <-
  bellabeat_weight %>% 
  summarise(average_weight=mean(WeightKg),
            min_weight=min(WeightKg),
            max_weight=max(WeightKg),
            average_BMI=mean(BMI),
            min_BMI=min(BMI),
            max_BMI=max(BMI))
head(weight_summary)
sleep_summary <-
  bellabeat_sleep %>% 
  summarise(average_sleep=mean(value),
            min_sleep=min(value),
            max_sleep=max(value))
head(sleep_summary)