In this project, we see the pattern of my exercise routine before pandemic, during the pandemic and after it.
Overall, the data tells me that I’m trying my best to get more exercise.
The data are collected from two devices: one from my iPhone Health App and one from my Garmin Smartwatch.
Both data complement each other to tell a complete story of my workout routine.
2020, the year of pandemic forced most of us to stay home. For me, I stayed home and didn’t get much exericse at all.
As we put pandemic behind us, I no longer just stayed home. I walk out a lot and exercise a lot.
Weekday and weekend do tell another side of story. I tend to have less exercise over the weekend. This is where I can improve.
---
title: "ANLY512 - Final Project"
author: "Hao Zhang"
output:
flexdashboard::flex_dashboard:
orientation: rows
vertical_layout: fill
theme: readable
source_code: embed
social: menu
---
```{r global, include=FALSE}
library(flexdashboard)
library(tidyverse)
library(viridis)
library(hrbrthemes)
library(DT)
library(plotly)
library(xts)
library(dygraphs)
theme = theme_ipsum() + theme(plot.caption = element_text(hjust=0, size=8),
plot.title = element_text(hjust = 0, size=12,
face="bold"),
axis.title.x = element_text(size=10),
axis.title.y = element_text(size=10))
```
# Overview
Column {.sidebar data-width=300}
-------------------------------------------------------------------
**Data description**
The dimension of pedometer walking dataset is (54386, 8).
The dataset is collected from iPhone Health App from 2015 to present day.
The two plots here are daily and monthly aggregated walking/running data measured in miles.
From the visualization, it's easy to tell that I'm trying to getting more exercise on a daily basis, regardless of weekday or weekend.
Overall, there are always exercises being recorded on any given day except an obvious drop period between March 2020 and July 2020 on both plots.
That was due to COVID-19 lock down.
```{r }
# aggregated walking data reading
walking_data_agg <- read.csv("walking_data_agg.csv")
```
Row
-------------------------------------------------------------------
### **Daily Pedometer Overview**
```{r }
# Convert the date column to a date format and set it as the index
walking_data_agg$date <- as.Date(walking_data_agg$date)
walking_data_xts <- xts(walking_data_agg$walking_distance, order.by = walking_data_agg$date)
names(walking_data_xts) <- c("Walking Distance")
# Create the dygraph
main <- "Overview of Daily Pedometer Data From 2015 to 2023" # Title
ylab <- 'Walking Distance (in Miles)' # Y-LAB
dygraph(walking_data_xts,
main = main,
ylab = ylab,
) %>%
dyHighlight(
highlightSeriesBackgroundAlpha = 0.5, # 1 - fully opaque, 0 - fully transparent
hideOnMouseOut = TRUE
) %>%
dyOptions(strokeWidth = 2, # 2 is good for visual
colors = "#9400d3",
) %>%
dyRangeSelector()
```
Row
-------------------------------------------------------------------
### **Monthly Pedometer Data Overview**
```{r }
# Convert the date column to a date format and set it as the index
walking_data_agg$date <- as.Date(walking_data_agg$date)
walking_data_xts <- xts(walking_data_agg$walking_distance, order.by = walking_data_agg$date)
names(walking_data_xts) <- c("Monthly Walking Distance")
# Create the dygraph
main <- "Overview of Monthy Pedometer Data From 2015 to 2023" # Title
ylab <- 'Walking Distance (in Miles)' # Y-LAB
dygraph(walking_data_xts,
main = main,
ylab = ylab,
) %>%
dyHighlight(
highlightSeriesBackgroundAlpha = 0.5, # 1 - fully opaque, 0 - fully transparent
hideOnMouseOut = TRUE
) %>%
dyOptions(strokeWidth = 2, # 2 is good for visual
colors ="red",
) %>%
dyRangeSelector()
```
# 2020 (Pandemic Hit)
Column {.sidebar data-width=300, .tabset data-height=550}
-------------------------------------------------------------------
**Data description**
March 2020 marked the month that COVID-19 officially reached everywhere in United States.
Starting early in March 2020, all non-essential workers were forced to stay home and work from home.
As you can see from the walking/running data in 2020, there was no activities between March 2020 and July 2020.
This was due to the severity of COVID-19.
Starting at July 2020, it was summer time and the status of COVID-19 eased a bit. I started my walking/running routine again.
On this page, the first tab is walking/running data on weekday of 2020.
The second tab is the data on weekend of 2020.
Usually, weekday have more walking/running. Between March 2020 and July 2020, it's clear that there is almost no exercise during this time period.
After July 2020, both weekday and weekend exercise are increasing comparing to pre-pandemic.
This is mainly due to the long time of staying home. I want to get more exercise.
```{r}
# Placeholder
```
Row {.tabset .tabset-fade}
-------------------------------------------------------------------
### **WEEKDAY Walking Overview 2020**
```{r }
YEAR <-2020 # Pandemic Year
walking_data_agg_year_weekend <- walking_data_agg %>%
filter(which_year == YEAR & is_weekend == "True") %>%
select(date, walking_distance)
walking_data_agg_year_weekday <- walking_data_agg %>%
filter(which_year == YEAR & is_weekend == "False") %>%
select(date, walking_distance)
xts_walking_data_agg_year_weekend <- xts(walking_data_agg_year_weekend[,-1], order.by = walking_data_agg_year_weekend$date)
xts_walking_data_agg_year_weekday <- xts(walking_data_agg_year_weekday[,-1], order.by = walking_data_agg_year_weekday$date)
names(xts_walking_data_agg_year_weekday) <- c("weekday walking distance")
names(xts_walking_data_agg_year_weekend) <- c("weekend walking distance")
main <- paste0("Overview Weekday Walking Distance of Year - ", YEAR) # Title
ylab <- 'Walking Distance (in Miles)' # Y-LAB
dygraph(xts_walking_data_agg_year_weekday,
main = main,
ylab = ylab,
) %>%
dyHighlight(
highlightSeriesBackgroundAlpha = 0.5, # 1 - fully opaque, 0 - fully transparent
hideOnMouseOut = TRUE
) %>%
dyOptions(strokeWidth = 2, # 2 is good for visual
colors = "tan",
) %>%
dyRangeSelector()
```
### **WEEKEND Walking Overview 2020 **
```{r }
main <- paste0("Overview Weekend Walking Distance of Year - ", YEAR) # Title
ylab <- 'Walking Distance (in Miles)' # Y-LAB
dygraph(xts_walking_data_agg_year_weekend,
main = main,
ylab = ylab,
) %>%
dyHighlight(
highlightSeriesBackgroundAlpha = 0.5, # 1 - fully opaque, 0 - fully transparent
hideOnMouseOut = TRUE
) %>%
dyOptions(strokeWidth = 2, # 2 is good for visual
colors = "#ff1493",
) %>%
dyRangeSelector()
```
# Walk (Weekend/Weekday)
Column {.sidebar data-width=300, .tabset data-height=550}
-------------------------------------------------------------------
**Data description**
As the majority of US population got vaccinated, people started returning to a normal life that's before pandemic.
For me, I have the options to both work on the premise and work from home. I tried to work in the office more often.
The Weekday plot shows a consistent walking/running data with a few days of exercises spiking up.
The Weekend plot showed an overall lower amount of walking/running data with quite a bit of variation.
Some days on weekends show lots of exercise data. This is mainly because I'm trying to find new local coffeeshop and try to find new local hangout places.
```{r}
# Placeholder
```
Row {.tabset .tabset-fade}
-------------------------------------------------------------------
### **WEEKDAY Walking Distance Overview**
```{r }
YEAR <-2022
walking_data_agg_year_weekend <- walking_data_agg %>%
filter(which_year == YEAR & is_weekend == "True") %>%
select(date, walking_distance)
walking_data_agg_year_weekday <- walking_data_agg %>%
filter(which_year == YEAR & is_weekend == "False") %>%
select(date, walking_distance)
xts_walking_data_agg_year_weekend <- xts(walking_data_agg_year_weekend[,-1], order.by = walking_data_agg_year_weekend$date)
xts_walking_data_agg_year_weekday <- xts(walking_data_agg_year_weekday[,-1], order.by = walking_data_agg_year_weekday$date)
names(xts_walking_data_agg_year_weekday) <- c("weekday walking distance")
names(xts_walking_data_agg_year_weekend) <- c("weekend walking distance")
main <- paste0("Overview Weekday Walking Distance of Year - ", YEAR) # Title
ylab <- 'Walking Distance (in Miles)' # Y-LAB
dygraph(xts_walking_data_agg_year_weekday,
main = main,
ylab = ylab,
) %>%
dyHighlight(
highlightSeriesBackgroundAlpha = 0.5, # 1 - fully opaque, 0 - fully transparent
hideOnMouseOut = TRUE
) %>%
dyOptions(strokeWidth = 2, # 2 is good for visual
colors = "#8da0cb",
) %>%
dyRangeSelector()
```
### **WEEKEND Walking Distance Overview**
```{r }
main <- paste0("Overview Weekend Walking Distance of Year - ", YEAR) # Title
ylab <- 'Walking Distance (in Miles)' # Y-LAB
dygraph(xts_walking_data_agg_year_weekend,
main = main,
ylab = ylab,
) %>%
dyHighlight(
highlightSeriesBackgroundAlpha = 0.5, # 1 - fully opaque, 0 - fully transparent
hideOnMouseOut = TRUE
) %>%
dyOptions(strokeWidth = 2, # 2 is good for visual
colors = "#a6d854",
) %>%
dyRangeSelector()
```
# Flight of Stairs (Climbing)
Column {.sidebar data-width=300, .tabset data-height=550}
-------------------------------------------------------------------
**Data description**
On this page show three different visualization.
The first one is overall flight of stairs climbing between 2015 and 2023.
The second plot is what happened in 2020. I stayed home between March 2020 and July 2020.
The last plot is the exercise routine in 2022.
There is a clear drop in activities in the early half of 2020. That was COVID-19.
Right after it, there is another clear drastically increasing effect in the first half of 2021.
Then we see a consistent exercise routine again.
I was motivated to get more exercise.
```{r}
flights_climb <-read.csv('flights_climb.csv')
flights_climb_agg <- read.csv('flights_climb_agg.csv')
```
Row {.tabset .tabset-fade}
-------------------------------------------------------------------
### **Flight of Stairs Climbing Daily**
```{r}
# Convert the date column to a date format and set it as the index
flights_climb_agg$date <- as.Date(flights_climb_agg$date)
flights_climb_agg_xts <- xts(flights_climb_agg$value, order.by = flights_climb_agg$date)
names(flights_climb_agg_xts) <- c("Daily_Flight_of_Stairs")
# Create the dygraph
main <- "Overview of Daily Flight of Stairs Climbing Data From 2015 to 2023" # Title
ylab <- 'Flight of Stairs Climbed' # Y-LAB
dygraph(flights_climb_agg_xts,
main = main,
ylab = ylab,
) %>%
dyHighlight(
highlightSeriesBackgroundAlpha = 0.5, # 1 - fully opaque, 0 - fully transparent
hideOnMouseOut = TRUE
) %>%
dyOptions(strokeWidth = 2, # 2 is good for visual
colors = "#dc143c",
) %>%
dyRangeSelector()
```
Row {.tabset .tabset-fade}
-------------------------------------------------------------------
### **Flight of Stairs Climbing Monthly View Before COVID-19 Pandemic Year 2020**
```{r}
# Convert the date column to a date format and set it as the index
YEAR <- 2020
flights_climb_agg_year <- flights_climb_agg %>%
filter(which_year == YEAR) %>%
select(date, value)
flights_climb_agg_year_xts <- xts(flights_climb_agg_year$value, order.by = flights_climb_agg_year$date)
names(flights_climb_agg_year_xts) <- c("Daily_Flight_of_Stairs")
# Create the dygraph
main <- paste0("Overview of Daily Flight of Stairs Climbing Data of YEAR ",YEAR) # Title
ylab <- 'Flight of Stairs Climbed' # Y-LAB
dygraph(flights_climb_agg_year_xts,
main = main,
ylab = ylab,
) %>%
dyHighlight(
highlightSeriesBackgroundAlpha = 0.5, # 1 - fully opaque, 0 - fully transparent
hideOnMouseOut = TRUE
) %>%
dyOptions(strokeWidth = 2, # 2 is good for visual
colors = "purple",
) %>%
dyRangeSelector()
```
Row {.tabset .tabset-fade}
-------------------------------------------------------------------
### **Flight of Stairs Climbing Monthly View After COVID-19 Pandemic Year 2022**
```{r}
# Convert the date column to a date format and set it as the index
YEAR <- 2022
flights_climb_agg_year <- flights_climb_agg %>%
filter(which_year == YEAR) %>%
select(date, value)
flights_climb_agg_year_xts <- xts(flights_climb_agg_year$value, order.by = flights_climb_agg_year$date)
names(flights_climb_agg_year_xts) <- c("Daily_Flight_of_Stairs")
# Create the dygraph
main <- paste0("Overview of Daily Flight of Stairs Climbing Data of YEAR ",YEAR) # Title
ylab <- 'Flight of Stairs Climbed' # Y-LAB
dygraph(flights_climb_agg_year_xts,
main = main,
ylab = ylab,
) %>%
dyHighlight(
highlightSeriesBackgroundAlpha = 0.5, # 1 - fully opaque, 0 - fully transparent
hideOnMouseOut = TRUE
) %>%
dyOptions(strokeWidth = 2, # 2 is good for visual
colors = "orange",
) %>%
dyRangeSelector()
```
# Complementary Data (Garmin Smartwatch)
Column {.sidebar data-width=300, .tabset data-height=550}
-------------------------------------------------------------------
**Data description**
The data we've seen so far were collected from my iPhone Health App.
However, the data is incomplete. Some of the times when I exercise, I won't even take my iPhone with me.
Lots of data were missing. Besides, the app wasn't able to capture all the data.
I have a Garmin Smartwatch that has the capability to recording other aspect of my exercise data.
Garmin smartwatch serves as my personal trainer to set up daily goals for me based on my previous exercise routine.
Here presents the daily goal from 2020, the year of pandemic and 2022, a year when life began returning to normal.
There's a clear drop in daily goal between March 2020 and July 2020 in the first plot.
As our lives return to normal, I'm trying to get more exercise and trying to beat my dail goal. That's the 2nd plot.
```{r}
garmin_data <- read.csv('Garmin_data.csv')
```
Row {.tabset .tabset-fade}
-------------------------------------------------------------------
### **Garmin-Complementary Daily Steps and Goal of Year 2020**
```{r}
garmin_data$calendarDate <- as.Date(garmin_data$calendarDate)
YEAR <- 2020
garmin_data_step_goals <- garmin_data %>%
filter(year == YEAR) %>%
select(calendarDate, totalSteps, dailyStepGoal)
garmin_data_step_goals_xts <- xts(garmin_data_step_goals[,-1], order.by = garmin_data_step_goals$calendarDate) # NOTE: remove date column, always assuming date field at the first place.
main <- paste0("Overview - Compare daily total step taken and daily goal of Year ", YEAR)
ylab <- "Step numbers"
dygraph(garmin_data_step_goals_xts,
main = main,
ylab = ylab,
) %>%
# reference: https://www.rdocumentation.org/packages/dygraphs/versions/1.1.1.6/topics/dyHighlight
dyHighlight(
highlightSeriesBackgroundAlpha = 0.5, # 1 - fully opaque, 0 - fully transparent
hideOnMouseOut = TRUE
) %>%
dyOptions(strokeWidth = 0, # scatter plot
drawPoints = TRUE,
pointSize = 5,
pointShape = "triangle",
colors = scales::hue_pal()(2),
) %>%
dyRangeSelector()
```
Row {.tabset .tabset-fade}
-------------------------------------------------------------------
### **Garmin-Complementary Daily Steps and Goal of Year 2022**
```{r}
garmin_data$calendarDate <- as.Date(garmin_data$calendarDate)
YEAR <- 2022
garmin_data_step_goals <- garmin_data %>%
filter(year == YEAR) %>%
select(calendarDate, totalSteps, dailyStepGoal)
garmin_data_step_goals_xts <- xts(garmin_data_step_goals[,-1], order.by = garmin_data_step_goals$calendarDate) # NOTE: remove date column, always assuming date field at the first place.
main <- paste0("Overview - Compare daily total step taken and daily goal of Year ", YEAR)
ylab <- "Step numbers"
dygraph(garmin_data_step_goals_xts,
main = main,
ylab = ylab,
) %>%
# reference: https://www.rdocumentation.org/packages/dygraphs/versions/1.1.1.6/topics/dyHighlight
dyHighlight(
highlightSeriesBackgroundAlpha = 0.5, # 1 - fully opaque, 0 - fully transparent
hideOnMouseOut = TRUE
) %>%
dyOptions(strokeWidth = 2, # plot
colors = scales::hue_pal()(2),
) %>%
dyRangeSelector()
```
# Summary
In this project, we see the pattern of my exercise routine before pandemic, during the pandemic and after it.
Overall, the data tells me that I'm trying my best to get more exercise.
The data are collected from two devices: one from my iPhone Health App and one from my Garmin Smartwatch.
Both data complement each other to tell a complete story of my workout routine.
2020, the year of pandemic forced most of us to stay home. For me, I stayed home and didn't get much exericse at all.
As we put pandemic behind us, I no longer just stayed home. I walk out a lot and exercise a lot.
Weekday and weekend do tell another side of story. I tend to have less exercise over the weekend. This is where I can improve.