Visualization dashboard is created with the help of my fitbit data. The data consists of my sleep and physical activities like Number of Steps per day, Distance walked, Calories Burned,heart rate and Sleep time. -From the data collected I proceeded to do the Exploratory Data Analysis to visualise the patterns and I will include Why I have choosen the Particular methods at the end.
By using the data driven approach I will summarize the 6 Quantified Self Questions:
1.What is the relation ship between Clories burnt and Heart Rate?
2.What are my weekly and monthly sleep habits?
3.What is the distance travelled per day?
4.What is the average daily activity pattern?
5.How much time do you sleep compared to the time spent on bed?
6.Finding the relationship between distance travelled and Calories Burnt?
I am using Flex Dashboard package to create a storyboard and doing the Visualizations of my fitbit data.
-About the Data The data is collected from my fitbit watch it tracks the heart rate ,sleep time, number of steps in a day, calories burnt.I have downloaded the data from fitbit app it supports csv or excel file and then I combined the files into one spreadsheet in Excel.
_Data Processing The dataset as the data from June 2018 to March 2019. I am aggregating the fitbit data by day because fitbit is capturing the data at minute level.Ignored the null values from the dataset. There are null values in the data on days where the FitBit was either charging or not worn.
_Methods and tools Installed different packages to build the dashboard. I have used tools like plotly,ggplot and dplyr.
-References https://rmarkdown.rstudio.com/flexdashboard/using.html#overview
Fitbit Quantified Self
Fitbit– Heart Rate
1._What is the relationship between Clories burnt and Heart Rate?
The calories burnt and heart rate are positively correlated . Higher the heart rate the calories burnt more.The minimum calories burnt are 1800 calories per day.
2.-What are my weekly and monthly sleep habits?
From the boxplot it shows the outliers because for few days the data is missing and compared to the weekly and montly sleep habits it is clear that i have more sleep on -Weekends when compared to weekdays and while comparing months i have more sleep in -Decemeber because I have more holidays during christmas.
3.-What is the distance travelled per day?
The minimum distance travelled per day was 700 meters and the highest distance travelled was 13.5 kms on an average the more distance was travelled in the month of Decemeber.
4.-What is the average daily activity pattern?
From the chart we can see that the average daily activity was less on weekends (sat,sun) when compared to weekdays.
5.-How much time do you sleep compared to the time spent on bed?
From the bar chart it shows that average time spent on bed was 7.5 hours a part of minuteAsleep is 6 hr 30 mnts.
6.-Finding the relationship between distance travelled and Calories Burnt?
From the scatter plot it shows distance travelled and calories burnt are correlated . The maximum distance travelled was 13kms and the calories burnt is 3700.
---
title: "Professor Alan Hitch ANLY 512 Final Project"
author: "Chandi Prasanna Malepu"
date: "`r Sys.Date()`"
output:
flexdashboard::flex_dashboard:
orientation: columns
storyboard: true
vertical_layout: fill
social: menu
source: embed
---
```{r setup, include=FALSE}
# The list of libraries required for dashboard.
knitr::opts_chunk$set(echo = FALSE)
library(dplyr)
library(flexdashboard)
library(knitr)
library(kableExtra)
library(ggplot2)
library(tidyverse)
library(readxl)
library(xts)
library(zoo)
library(scales)
library(lubridate)
library(cowplot)
library(dygraphs)
library(plotly)
library(metricsgraphics)
library(reshape)
library(png)
```
### OverView of Quantified Self movement
Visualization dashboard is created with the help of my fitbit data. The data consists of my sleep and physical activities like Number of Steps per day, Distance walked, Calories Burned,heart rate and Sleep time.
-**From the data collected I proceeded to do the Exploratory Data Analysis to visualise the patterns and I will include Why I have choosen the Particular methods at the end**.
By using the data driven approach I will summarize the 6 Quantified Self Questions:
1.What is the relation ship between Clories burnt and Heart Rate?
2.What are my weekly and monthly sleep habits?
3.What is the distance travelled per day?
4.What is the average daily activity pattern?
5.How much time do you sleep compared to the time spent on bed?
6.Finding the relationship between distance travelled and Calories Burnt?
I am using Flex Dashboard package to create a storyboard and doing the Visualizations of my fitbit data.
-**About the Data**
The data is collected from my fitbit watch it tracks the heart rate ,sleep time, number of steps in a day, calories burnt.I have downloaded the data from fitbit app it supports csv or excel file and then I combined the files into one spreadsheet in Excel.
_**Data Processing**
The dataset as the data from June 2018 to March 2019. I am aggregating the fitbit data by day because fitbit is capturing the data at minute level.Ignored the null values from the dataset. There are null values in the data on days where the FitBit was either charging or not worn.
_**Methods and tools**
Installed different packages to build the dashboard.
I have used tools like plotly,ggplot and dplyr.
-**References**
https://rmarkdown.rstudio.com/flexdashboard/using.html#overview
***
Fitbit Quantified Self

Fitbit-- Heart Rate

```{r}
#Loading the dataframes into R
calories <- read.csv("D:/Tues day 512/fitbit_data/calories.csv")
distance <- read.csv("D:/Tues day 512/fitbit_data/distance.csv")
heart_rate <- read.csv("D:/Tues day 512/fitbit_data/heart_rate.csv")
steps <- read.csv("D:/Tues day 512/fitbit_data/steps.csv")
sleep <- read.csv("D:/Tues day 512/fitbit_data/sleep.csv")
calories$JoiningDate <- as.Date(calories$dateTime , "%m/%d/%y")
distance$JoiningDate <- as.Date(distance$dateTime , "%m/%d/%y")
heart_rate$JoiningDate <- as.Date(heart_rate$dateTime , "%m/%d/%y")
steps$JoiningDate <- as.Date(steps$dateTime , "%m/%d/%y")
#view(calories)
calories_new <- calories %>% group_by(JoiningDate) %>%
summarise(calories_value = sum(value, na.rm = TRUE))
#view(calories_new)
distance_new <- distance %>% group_by(JoiningDate) %>%
summarize(distance_value = sum(value/100000, na.rm = TRUE))
heart_rate_new <- heart_rate %>% group_by(JoiningDate) %>%
summarize(heart_rate_value = mean(bpm, na.rm = TRUE))
steps_new <- steps %>% group_by(JoiningDate) %>%
summarize(steps_value = sum(value, na.rm = TRUE))
#Joining the 4 dataframes into 1 frame.
first_join = left_join(calories_new, distance_new ,by = "JoiningDate")
Second_join = left_join(first_join, steps_new, by = "JoiningDate")
full_join = left_join(Second_join, heart_rate_new, by = "JoiningDate")
Fitbit_Data <- filter(full_join, JoiningDate >= "2018-06-01")
Fitbit_Data$month<-format(Fitbit_Data$JoiningDate,"%m")
Fitbit_Data$dayofweek <-wday(Fitbit_Data$JoiningDate, label=TRUE, abbr=FALSE)
#sapply(Fitbit_Data, function(x) sum(is.na(x))) # checking the null values
#sapply(sleep,function(x) sum(is.na(x)))
#Removing the null values.
Fitbit_Data <- Fitbit_Data[complete.cases(Fitbit_Data),]
#sleep <- sleep[complete.cases(sleep),]
```
```{r}
# Dataset View
#str(Fitbit_Data)
#summary(Fitbit_Data)
```
###calories vs heart rate
```{r}
mjs_plot(Fitbit_Data, x=calories_value, y=heart_rate_value) %>%
mjs_point(color_accessor=calories_value, size_accessor=heart_rate_value) %>%
mjs_labs(x="Calories", y="Hear Rate")
```
### weekly and monthly sleep habits
```{r}
fill <- "red"
line <- "goldenrod2"
sleep$Month <- month(parse_date_time(sleep[,1], '%y/%m/%d'), label=TRUE)
sleep$dayofweek <- wday(sleep$dateOfSleep, label=TRUE, abbr=FALSE)
ggplot(sleep, aes(x = dayofweek, y=duration/3600000)) +
geom_boxplot(aes(group = dayofweek), fill = fill, colour = line) +
scale_x_discrete(limits=c("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")) +
labs(title = "Hours asleep per week day", x = "Weekdays", y = "Hours") +
theme_minimal()
ggplot(sleep, aes(x = Month, y=duration/3600000)) +
geom_boxplot(aes(group = Month), fill = fill, colour = line) +
scale_x_discrete(limits=c("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")) +
labs(title = "Hours asleep per month", x = "Months", y = "Hours") +
theme_minimal()
```
###Distance Travelled
```{r}
plot_ly(Fitbit_Data, x = ~JoiningDate , y = ~distance_value, type = 'scatter', mode = 'lines') %>%
layout(
title = 'Line chart for distance travelled in Kilometers ',
xaxis = list(
title = 'Days'
),
yaxis = list(
title = 'Distance travelled in Kilometers'
)
)
```
### Daily Activity
```{r}
ggplot(Fitbit_Data, aes(x=Fitbit_Data$month, y=Fitbit_Data$steps_value, fill=Fitbit_Data$dayofweek)) +
geom_bar(stat="identity")+theme_minimal() + ggtitle("Total Steps Taken by Month Stacked by Week of the Day") +
labs(x="Month", y="Total Number of Steps Taken", fill="Day of the Week")
```
### sleep compared to time spent on bed
```{r}
sleep_new <- sleep %>%
select(Month, minutesAsleep, timeInBed)
data.m <- melt(sleep_new, id.vars='Month')
ggplot(data.m, aes(Month, value/60)) +
geom_bar(aes(fill = variable), position = "dodge", stat="identity") + xlab("Average of Monthly sleep") + ylab("Number of Hours")
```
### Relationship between Distance travelled and calories Burnt
```{r}
plot_ly(data = Fitbit_Data, x = ~distance_value, y = ~calories_value,color = ~dayofweek, type = "scatter" , mode = "markers") %>% layout (title = 'Interactive scatter plot of the distance walked/Calories Burned',
xaxis = list(
title = 'Distance travelled in Kilometers'
),
yaxis = list(
title = 'Calories Burnt'
)
)
```
### Conclusion for the above questions
1._**What is the relationship between Clories burnt and Heart Rate**?
The calories burnt and heart rate are positively correlated . Higher the heart rate the calories burnt more.The minimum calories burnt are 1800 calories per day.
2.-**What are my weekly and monthly sleep habits**?
From the boxplot it shows the outliers because for few days the data is missing and compared to the weekly and montly sleep habits it is clear that i have more sleep on -**Weekends** when compared to weekdays and while comparing months i have more sleep in -**Decemeber** because I have more holidays during christmas.
3.-**What is the distance travelled per day**?
The minimum distance travelled per day was 700 meters and the highest distance travelled was 13.5 kms on an average the more distance was travelled in the month of Decemeber.
4.-**What is the average daily activity pattern**?
From the chart we can see that the average daily activity was less on weekends (sat,sun) when compared to weekdays.
5.-**How much time do you sleep compared to the time spent on bed**?
From the bar chart it shows that average time spent on bed was 7.5 hours a part of minuteAsleep is 6 hr 30 mnts.
6.-**Finding the relationship between distance travelled and Calories Burnt**?
From the scatter plot it shows distance travelled and calories burnt are correlated . The maximum distance travelled was 13kms and the calories burnt is 3700.