This dashboard is a Self-Quantified Project. It shows the analysis of various day-to -day routine like number of cups of coffee per day, number of hours of sleep per day, steps and walking distance per day and time spent on various other activities like watching TV, workout, reading, etc.
Data was collected both manually and electronically. Data for variables such steps and walking distance per day, number of hours of phone use were collected via smart watch and phone where as number of cups of coffee per day, number of hours of sleep per day, time spent on watching TV, time spent on reading and time spent working out was recorded manually. All the data was consolidated in an excel sheet and used for the analysis.
The objective of this dashboard is to assess my daily routine and living habits. The main questions the dashboard tries to answer are:
How many steps do I walk in a day? Which are the most active days in the week?
How many calories do I burn every day? Is there a correlation between my activities and calories burned?
How is my sleeping routine?
How many coffee do I drink? Does drinking coffee has any correlation with activity or sleep pattern?
How do I spend my usual day?
Based on the dashboard following observations can be made:
• I walk roughly 15k steps a day. This is because I have to walk to and from work to train station. Also, I have to go out for lunch.
• I work out pretty regularly during the weekdays which also adds to my step count.
• Active calories burned are higher during the weekday when I go to work and also workout.
• I drink around 2 cups of coffee a day during the weekdays. During weekend my coffee consumption increase as I am mostly out travelling.
• I sleep roughly between 7 to 8 hours a day. Sleep is less on Friday and Saturday nights as usually I am on the road and hence coffee consumption increases the next day.
• I spend an unusually high amount of time on phone i.e. 3-4 hours which I never realized. This time can be reduced and better utilized.
• I make it a point to read daily at least for 30 min or so.
• I spend a lot of time watching TV daily which also can reduced and utilized better.
---
title: "The Quantified Self"
subtitle: "Final project for ANLY 512: Data Visualization"
author: "Nadeem Jamal"
date: "`r Sys.Date()`"
output:
flexdashboard::flex_dashboard:
orientation: rows
social: menu
source_code: embed
---
```{r setup, include=FALSE, message=FALSE}
knitr::opts_chunk$set(echo = FALSE)
#load library
library(readxl)
library(tidyverse)
library(ggplot2)
library(ggthemes)
library(plotly)
library(dygraphs)
library(xts)
library(latticeExtra)
library(flexdashboard)
library(quantmod)
library(plyr)
library(lubridate)
library(RColorBrewer)
library(DT)
library(scales)
#import the dataset
self = read_xlsx("C:\\My\\Harris\\Course\\ANLY 512\\Project\\finprojdata.xlsx")
#take a look at the dataset and see their data types
glimpse(self)
##Pre-processing
self$Date = as.Date(self$Date)
self$Phone_Use = as.numeric(self$Phone_Use)
self$Sleeping= as.numeric(self$Sleeping)
glimpse(self)
#Add a weekday variable to the dataset
self1 <- self
self1$weekday = weekdays(self1$Date)
self = self1
## setting levels
self$weekday = factor(self$weekday,levels= c( "Monday",
"Tuesday", "Wednesday", "Thursday", "Friday", "Saturday","Sunday"))
```
# PROJECT OVERVIEW
### Objective
This dashboard is a Self-Quantified Project. It shows the analysis of various day-to -day routine like number of cups of coffee per day, number of hours of sleep per day, steps and walking distance per day and time spent on various other activities like watching TV, workout, reading, etc.
Data was collected both manually and electronically. Data for variables such steps and walking distance per day, number of hours of phone use were collected via smart watch and phone where as number of cups of coffee per day, number of hours of sleep per day, time spent on watching TV, time spent on reading and time spent working out was recorded manually. All the data was consolidated in an excel sheet and used for the analysis.
The objective of this dashboard is to assess my daily routine and living habits. The main questions the dashboard tries to answer are:
1. How many steps do I walk in a day? Which are the most active days in the week?
2. How many calories do I burn every day? Is there a correlation between my activities and calories burned?
3. How is my sleeping routine?
4. How many coffee do I drink? Does drinking coffee has any correlation with activity or sleep pattern?
5. How do I spend my usual day?
# MOVEMENT
Row
-------------------------------------
### Steps by Weekday
```{r message=FALSE, warning=FALSE}
plot_ly(self, y = ~Steps, color= ~weekday, type="box", boxpoints = "all") %>%
layout(title="Steps per Day", yaxis=list(title="Number of Steps"), xaxis=list(title="Day"))
```
### Walking and Running Distance by Weekday
```{r message=FALSE, warning=FALSE}
plot_ly(self, y = ~Walking_and_Running, color= ~weekday, type="box", boxpoints = "all") %>%
layout(title="Walking and Running Distance per Day", yaxis=list(title="Number of Hours"), xaxis=list(title="Day"))
```
Row
-------------------------------------
### Steps vs Calories burned
```{r,echo=FALSE, message = FALSE}
energy_burned = xts(self[,c(1,10,11)], order.by = self$Date)
p <- plot_ly(self) %>%
add_trace(x = ~Date, y = ~Steps, type = 'bar', name = 'steps',
marker = list(color = '#C9EFF9'),
hoverinfo = "text",
text = ~paste(Steps, ' steps')) %>%
add_trace(x = ~Date, y = ~Base_Calorie_Burned, type = 'scatter', mode = 'lines', name = 'Base_Calorie_Burned', yaxis = 'y2',
line = list(color = 'Red'),
hoverinfo = "text",
text = ~paste(Base_Calorie_Burned, 'kcal')) %>%
add_trace(x = ~Date, y = ~Active_Calorie_Burned, type = 'scatter', mode = 'lines', name = 'Active_Calorie_Burned', yaxis = 'y2',
line = list(color = 'Orange'),
hoverinfo = "text",
text = ~paste(Active_Calorie_Burned, 'kcal')) %>%
layout(title = 'Steps vs Calories Burned',
# paper_bgcolor= 'Orange',
# plot_bgcolor= "Orange",
xaxis = list(title = "Day"),
yaxis = list(side = 'left', title = 'Steps', showgrid = FALSE, zeroline = FALSE),
yaxis2 = list(side = 'right', overlaying = "y", title = 'Calories Burned', showgrid = FALSE, zeroline = FALSE))
p
```
SLEEP AND COFFEE USE
=====================================
Row
-------------------------------------
### Coffee Use by Weekday
```{r message=FALSE, warning=FALSE}
plot_ly(self, y = ~Coffee, color= ~weekday, type="box", boxpoints = "all") %>%
layout(title="Coffee use by Weekday", yaxis=list(title="No. of Coffee"), xaxis=list(title="Day"))
```
### Sleeping Hour Per Weekday
```{r message=FALSE, warning=FALSE}
plot_ly(self, y = ~Sleeping, color= ~weekday, type="box", boxpoints = "all") %>%
layout(title="Sleeping Hour per Day", yaxis=list(title="Number of Hours"), xaxis=list(title="Day"))
```
Row
-------------------------------------
### Sleeping Hour vs Coffee Use
```{r, message=FALSE, warning=FALSE}
ggplotly(ggplot(self,aes(x = Sleeping, y = Coffee))+ geom_point(col = 'blue') + geom_smooth(col = 'blue', fill = "light blue") +
geom_jitter(col = "blue") +
theme_classic() +
ggtitle("Sleeping Hour vs Coffee Use") +
labs(x = "Sleeping Hours", y = "Coffee Use (Cup)"))
```
### Coffee Use vs Sleeping Hour
```{r message=FALSE, warning=FALSE}
coffee = xyplot(Coffee ~ Date, self, type = "l" , lwd=2)
sleeping = xyplot(Sleeping ~ Date, self, type = "l" , lwd=2)
doubleYScale(coffee, sleeping, text = c("Coffee Use", "Sleeping Hour") , add.ylab2 = TRUE)
```
TIME USE
=====================================
Row
-------------------------------------
### Time Use Per Day
```{r message=FALSE, warning=FALSE}
timeuse = self %>% mutate(other = 24 - Sleeping-Watching_TV-Phone_Use-Reading-Workout)
timeuse = xts(timeuse[,c(3,4,8,9,7,14)], order.by = timeuse$Date)
dygraph(timeuse,main = "Time Use By Date") %>% dyAxis("y", label = "Hour") %>%
dyLegend(width = 700) %>%
dyRangeSelector(height = 100) %>%
dyOptions(stackedGraph = TRUE)
```
CONCLUSION
=====================================
### Conclusion
Based on the dashboard following observations can be made:
• I walk roughly 15k steps a day. This is because I have to walk to and from work to train station. Also, I have to go out for lunch.
• I work out pretty regularly during the weekdays which also adds to my step count.
• Active calories burned are higher during the weekday when I go to work and also workout.
• I drink around 2 cups of coffee a day during the weekdays. During weekend my coffee consumption increase as I am mostly out travelling.
• I sleep roughly between 7 to 8 hours a day. Sleep is less on Friday and Saturday nights as usually I am on the road and hence coffee consumption increases the next day.
• I spend an unusually high amount of time on phone i.e. 3-4 hours which I never realized. This time can be reduced and better utilized.
• I make it a point to read daily at least for 30 min or so.
• I spend a lot of time watching TV daily which also can reduced and utilized better.