This project aims to use the flex dashboard to vitalize my 35 days health tracker (Nov. 8, 2022, to Dec. 12, 2022). And I am generating five questions that can be evaluated using a data-driven approach. The original purpose of this data collection is to track my health status. I want to learn if there is any association between my sleep duration, weight change, and test completion status. I collected this data to encourage myself to live more efficiently.
In this database, I captured my sleep duration for 35 days, my energy intake (net weight gain and loss between 8 am and 10 pm every day), my exercise status, and my lifestyle(grocery, food take-out). Some self-evaluate variables (e.g., daily task completion status, mood, confidence status, etc.).
Question 1: From Nov. 8, 2023 - Dec. 12, 2023, what is the distribution of my sleep duration in Hours? If 7 hours are the cutoff value of adequate sleep, how many days were adequate? If 5 hours is the cutoff value for extremely inadequate sleep, how many days is my sleep extremely inadequate? What is the adequate sleep rate and extremely inadequate sleep rate?
Question 2: Is there any association between Sleep duration and weight loss during sleep? How does exercise(aerobic and anaerobic) affect this association?
Question 3: How is ordering food takeout affect the daily weight gain in kilograms? Compare and contrast the daily weight gain situation between ordering food takeout or not ordering food takeout.
Question 4: How does the task completion status affect the association between my sleep duration and daily weight change during sleep? Describe the task completion status in 35 days.
Question 5: During these 35 days, what is the satisfactory level of my mood and confidence status? How does the task completion affect the quality of my mood and confidence status?
Time frame: (Nov. 8, 2022, to Dec. 12, 2022) 35 days
Variable:
Sleep Duration: Continuous varibale, in Hours,record by Fitbit.
Intake: Net weight gain from 8 am to 10 pm. In Kilogram, record by electronic weight.
consume: Net weight loss from 10 pm to 8 am. In Kilogram, record by electronic weight.
Binary variable ( Yes/ No)
Aerobic:( Yes/ No)
Anaerobic:( Yes/ No)
Take-out: order food deliver or not
Grocery: Buying Grocery or not
Satisfactory liker scale ( level 1 = Very Unsatisfied, 3 = Neutral, 5 = Very Satisfied)
Task: Task completion status, 0% to 100%, 5 level categorical
Mood: Satisfactory liker scale ( level 1 = Very Unsatisfied, 3 = Neutral, 5 = Very Satisfied)
Confidence: Confidence level, Satisfactory liker scale ( level 1 = Very Unsatisfied, 3 = Neutral, 5 = Very Satisfied)
Question 1: From Nov. 8, 2023 - Dec. 12, 2023, what is the distribution of my sleep duration in Hours? If 7 hours are the cutoff value of adequate sleep, how many days were adequate? If 5 hours is the cutoff value for extremely inadequate sleep, In how many days my sleep is extremely inadequate? What is the adequate sleep rate and extremely inadequate sleep rate?
The skyblue horizontal line indicate sleep hour = 7, and the Red horizontal line indicate sleep hour = 5.
Overall, I had 5 days of adequate sleep, and 11 days extremely inadequate sleep. The average sleep duration for these 35 days is 5.67. I don’t think I was in a good sleep condition during this period.
The percentage of days I had an adequate sleep in this 35 days is 14%, and The percentage of days I had an extremely unadequate sleep in this 35 days is 31%
Question 2: Is there any association between Sleep duration and the weight change during sleep? How dose exercise(aerobic and anaerobic) affect this association?
There were not statistically significant association between Sleep Duration and weight change during sleep. However, I notice when I was doing an anaerobic activity, My sleep hour will be relatively higher than not having any anaerobic activity.
Ordering food takeout create lots of challenge for me to record my diet. I could not control the amount of sodium and oil in the food takeout, but this food takeout tasted so good. I would like to know how ordering food takeout would affect my daily weight gain in these 35 days.
Question 3: How is ordering food takeout affect the daily weight gain in kilograms? Compare and contrast the daily weight gain situation between ordering food takeout or not ordering food takeout.
Although the graph indicates the medium of daily weight gain is higher when ordering a food takeout, The t-test result suggests that the difference is not statistically significant. In addition, based on the data visualization results, the range of daily weight gain in kg was more extensive when I was not ordering food takeout. Maybe I needed to be more careful with how much food I ate when I cooked at home.
I am usually super stressed when I don’t complete my daily task, and based on my experience, the task completion status will affect my sleep quality and duration. I want to evaluate the relationship between my sleep duration and task completion status. The task completion status was recorded as 1 = 0%, 2 = 25%. 3 = 50%, 4 = 75%, and 5 =100%.
Question 4: How does the task completion status affect the association between my sleep duration and daily weight change during sleep? Describe the task completion status in 35 days.
Based on the line graph, there was a positive association between sleep duration and daily weight change during sleep when task completion status is 75% and 100%. However, when task completion rates were 50%, 25%, and 0%, there was a negative association between sleep duration and daily weight change during sleep.
The description of the task completion status shows in the pie chart.
I am usually super stressed when I don’t complete my daily task, and based on my experience, the task completion status will affect my sleep quality and duration. I want to evaluate the relationship between my sleep duration and task completion status. I want to assess my mental health status(confidence) and mood regarding the task completion status. There was a hypothesis that daily task completion level will affect people’s mental health status, feelings, and mood. I would like to know if this is true.
Question 5: During these 35 days, what is the satisfactory level of my mood and confidence status? How does the task completion affect the quality of my mood and confidence status?
---
title: "ANLY 512 SP2023 Course Project"
author: "Sun,Shengxi"
date: "April 25, 2023"
output:
flexdashboard::flex_dashboard:
source_code: embed
social: menu
orientation: columns
vertical_layout: fill
---
```{r setup, include=FALSE}
library(flexdashboard)
library(ggplot2)
library(dplyr)
library(quantmod)
library(dygraphs)
library(maps)
library(ggmap)
library(maptools)
library(readr)
health<- read_csv("Health.csv")
summary(health)
str(health)
health$Aerobic[health$Aerobic=="Yes"] <- " Yes"
health$Anaerobic[health$Anaerobic=="Yes"] <- " Yes"
health$Take_out[health$Take_out=="Yes"] <- " Yes"
health$Grocery[health$Grocery=="Yes"] <- " Yes"
health$Task[health$Task=="75%"] <- " 75%"
health$Task[health$Task=="50%"] <- " 50%"
health$Task[health$Task=="25%"] <- " 25%"
health$Task[health$Task=="0%"] <- " 0%"
health$Mood[health$Mood=="Satisfied"] <- " Satisfied"
health$Mood[health$Mood=="Neutral"] <- " Neutral"
health$Mood[health$Mood=="Unsatisfied"] <- " Unsatisfied"
health$Mood[health$Mood=="Very Unsatisfied"] <- " Very Unsatisfied"
health$Confidence[health$Confidence=="Satisfied"] <- " Satisfied"
health$Confidence[health$Confidence=="Neutral"] <- " Neutral"
health$Confidence[health$Confidence=="Unsatisfied"] <- " Unsatisfied"
health$Confidence[health$Confidence==" Very Unsatisfied"] <- " Very Unsatisfied"
cleanup <- theme(panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
panel.background = element_blank(),
axis.line.x = element_line(color = "black"),
axis.line.y = element_line(color = "black"),
legend.key = element_rect(fill = "white"),
text = element_text(size = 15))
```
# Final Project Overview
Row {data-height=400}
-------------------------------------
### **Objective**
This project aims to use the flex dashboard to vitalize my 35 days health tracker (Nov. 8, 2022, to Dec. 12, 2022). And I am generating five questions that can be evaluated using a data-driven approach. The original purpose of this data collection is to track my health status. I want to learn if there is any association between my sleep duration, weight change, and test completion status. I collected this data to encourage myself to live more efficiently.
In this database, I captured my sleep duration for 35 days, my energy intake (net weight gain and loss between 8 am and 10 pm every day), my exercise status, and my lifestyle(grocery, food take-out). Some self-evaluate variables (e.g., daily task completion status, mood, confidence status, etc.).
* Question 1: From Nov. 8, 2023 - Dec. 12, 2023, what is the distribution of my sleep duration in Hours? If 7 hours are the cutoff value of adequate sleep, how many days were adequate? If 5 hours is the cutoff value for extremely inadequate sleep, how many days is my sleep extremely inadequate? What is the adequate sleep rate and extremely inadequate sleep rate?
* Question 2: Is there any association between Sleep duration and weight loss during sleep? How does exercise(aerobic and anaerobic) affect this association?
* Question 3: How is ordering food takeout affect the daily weight gain in kilograms? Compare and contrast the daily weight gain situation between ordering food takeout or not ordering food takeout.
* Question 4: How does the task completion status affect the association between my sleep duration and daily weight change during sleep? Describe the task completion status in 35 days.
* Question 5: During these 35 days, what is the satisfactory level of my mood and confidence status? How does the task completion affect the quality of my mood and confidence status?
Row {data-weight=600}
-------------------------------------
### **Data collection Method**
Time frame: (Nov. 8, 2022, to Dec. 12, 2022) 35 days
Variable:
* Sleep Duration: Continuous varibale, in Hours,record by Fitbit.
* Intake: Net weight gain from 8 am to 10 pm. In Kilogram, record by electronic weight.
* consume: Net weight loss from 10 pm to 8 am. In Kilogram, record by electronic weight.
Binary variable ( Yes/ No)
* Aerobic:( Yes/ No)
* Anaerobic:( Yes/ No)
* Take-out: order food deliver or not
* Grocery: Buying Grocery or not
Satisfactory liker scale ( level 1 = Very Unsatisfied, 3 = Neutral, 5 = Very Satisfied)
* Task: Task completion status, 0% to 100%, 5 level categorical
* Mood: Satisfactory liker scale ( level 1 = Very Unsatisfied, 3 = Neutral, 5 = Very Satisfied)
* Confidence: Confidence level, Satisfactory liker scale ( level 1 = Very Unsatisfied, 3 = Neutral, 5 = Very Satisfied)
# Sleep Overview
Row {data-width=700}
------------------------------
### Data overview:
Question 1: From Nov. 8, 2023 - Dec. 12, 2023, what is the distribution of my sleep duration in Hours? If 7 hours are the cutoff value of adequate sleep, how many days were adequate? If 5 hours is the cutoff value for extremely inadequate sleep, In how many days my sleep is extremely inadequate? What is the adequate sleep rate and extremely inadequate sleep rate?
### Sleep Duration - Nov. 8, 2023 - Dec. 12, 2023
```{r}
f1 = ggplot(data=health, aes(x=Date, y=Sleep)) +
geom_bar(stat='identity')+
geom_hline(yintercept = 7, color = "skyblue")+
geom_hline(yintercept = 5, color = "red")+
scale_x_discrete(limits=health$Date)+
theme(axis.text.x=element_text(angle=45, vjust = 0.6, size = 9))+
labs(title="Sleep hours in 35 days")+
cleanup
f1
```
Row {data-height=320}
------------------------------
### Summary:
* The skyblue horizontal line indicate sleep hour = 7, and the Red horizontal line indicate sleep hour = 5.
* Overall, I had 5 days of adequate sleep, and 11 days extremely inadequate sleep. The average sleep duration for these 35 days is 5.67. I don't think I was in a good sleep condition during this period.
* The percentage of days I had an adequate sleep in this 35 days is 14%, and The percentage of days I had an extremely unadequate sleep in this 35 days is 31%
# Sleep Duration vs. Weight Consumption
Row {data-height=320}
------------------------------
### Question:
Question 2: Is there any association between Sleep duration and the weight change during sleep? How dose exercise(aerobic and anaerobic) affect this association?
There were not statistically significant association between Sleep Duration and weight change during sleep. However, I notice when I was doing an anaerobic activity, My sleep hour will be relatively higher than not having any anaerobic activity.
## The association between sleep duration and weight loss during sleep in kg
### Group by Aerobic
```{r}
health_summary <- health %>%
select(consume, Sleep, Aerobic) %>%
group_by(Aerobic)
ggplot(health, aes(x = Sleep, y = consume)) +
geom_point(aes(col = Aerobic)) +
geom_smooth(method = "lm") +
labs( x = "Sleep hours", y = "Weight loss in sleep (kg)", title = "The association between sleep duration and weight loss during sleep", col = "Aerobic")
```
### Group by Anaerobic
```{r}
health_summary <- health %>%
select(consume, Sleep, Anaerobic) %>%
group_by(Anaerobic)
ggplot(health, aes(x = Sleep, y = consume)) +
geom_point(aes(col = Anaerobic)) +
geom_smooth(method = "lm") +
labs( x = "Sleep hours", y = "Weight loss in sleep (kg)", title = "The association between sleep duration and weight loss during sleep",col = "Anaerobic")
```
## sleep duration and weight loss during sleep in kg {.}
### Sleep duration in hours by Anaeribic
```{r}
ggplot(health, aes(x=Anaerobic, y= Sleep)) +
geom_boxplot(fill="skyblue")+
cleanup+
labs(title = "Sleep duration in hours by Anaerobic")+
theme(plot.title = element_text(hjust = 0.5))
```
### Sleep duration in hours by Aeribic
```{r}
ggplot(health, aes(x=Aerobic, y= Sleep)) +
geom_boxplot(fill="skyblue")+
cleanup+
labs(title = "Sleep duration in hours by Aerobic")+
theme(plot.title = element_text(hjust = 0.5))
```
# Food Take-out and Daily Weight gain
Row {data-width=600}
------------------------------
### Question
Ordering food takeout create lots of challenge for me to record my diet. I could not control the amount of sodium and oil in the food takeout, but this food takeout tasted so good. I would like to know how ordering food takeout would affect my daily weight gain in these 35 days.
Question 3: How is ordering food takeout affect the daily weight gain in kilograms? Compare and contrast the daily weight gain situation between ordering food takeout or not ordering food takeout.
Although the graph indicates the medium of daily weight gain is higher when ordering a food takeout, The t-test result suggests that the difference is not statistically significant. In addition, based on the data visualization results, the range of daily weight gain in kg was more extensive when I was not ordering food takeout. Maybe I needed to be more careful with how much food I ate when I cooked at home.
Row {data-width=700}}
------------------------------
### Food Deliver
```{r}
ggplot(health, aes(x=Take_out, y= Intake)) +
geom_boxplot(fill="darkred")+
cleanup+
labs(title = "Daily weight gain in kg by ordering food takeout")+
theme(plot.title = element_text(hjust = 0.5))
```
# Task Completion Status
Row {data-width=600}
------------------------------
### Question
I am usually super stressed when I don't complete my daily task, and based on my experience, the task completion status will affect my sleep quality and duration. I want to evaluate the relationship between my sleep duration and task completion status. The task completion status was recorded as 1 = 0%, 2 = 25%. 3 = 50%, 4 = 75%, and 5 =100%.
Question 4: How does the task completion status affect the association between my sleep duration and daily weight change during sleep? Describe the task completion status in 35 days.
Based on the line graph, there was a positive association between sleep duration and daily weight change during sleep when task completion status is 75% and 100%. However, when task completion rates were 50%, 25%, and 0%, there was a negative association between sleep duration and daily weight change during sleep.
The description of the task completion status shows in the pie chart.
Row {data-width=700}}
------------------------------
### Task completion status, Sleep, and weight change during sleep.
```{r}
ggplot(health, aes(x = Sleep, y = consume, color = Task, fill = Task)) +
geom_point(color = "blue") +
geom_smooth(method = 'lm',color = "green") +
labs( x = "Sleep Duration (hrs)", y = "Weight change during sleep (kg)", )
```
Row {data-width=700}}
------------------------------
### Description of Task Completion status in 35 days.
```{r}
ggplot(health, aes(x=factor(1), fill=Task))+
geom_bar(width = 1)+
coord_polar("y")
```
# Self-evaluation Likert Scale
Row {data-width=600}
------------------------------
### Question
I am usually super stressed when I don't complete my daily task, and based on my experience, the task completion status will affect my sleep quality and duration. I want to evaluate the relationship between my sleep duration and task completion status. I want to assess my mental health status(confidence) and mood regarding the task completion status. There was a hypothesis that daily task completion level will affect people's mental health status, feelings, and mood. I would like to know if this is true.
Question 5: During these 35 days, what is the satisfactory level of my mood and confidence status? How does the task completion affect the quality of my mood and confidence status?
## Self-evaluation Likert Scale {.tabset data-width=1000}
### Mood Satisfaction
```{r}
ggplot (health, aes(x = Mood, fill = Task)) +
geom_bar() +
theme_bw() +
theme(axis.text.x=element_text(angle = -45, hjust = 0)) +
labs(title = "Mood Satisfaction status by Task Completion",
x = "Mood Satisfaction status",
y = "Count")
```
### Confidence Satisfaction
```{r}
ggplot (health, aes(x = Confidence, fill = Task)) +
geom_bar() +
theme_bw() +
theme(axis.text.x=element_text(angle = -45, hjust = 0)) +
labs(title = "Confedence Satisfaction status by Task Completion",
x = "Confidence Satisfaction status",
y = "Count")
```