knitr::opts_chunk$set(echo=FALSE)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.2     ✔ readr     2.1.4
## ✔ forcats   1.0.0     ✔ stringr   1.5.0
## ✔ ggplot2   3.4.3     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.0
## ✔ 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
## Loading required package: viridisLite
## 
## 
## Attaching package: 'plotly'
## 
## 
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## 
## 
## The following object is masked from 'package:stats':
## 
##     filter
## 
## 
## The following object is masked from 'package:graphics':
## 
##     layout

#Intro College students are notorious for erratic sleep schedules, influenced by academic demands, social activities, and extracurricular commitments. The average college student often juggles a delicate balance between coursework, social engagements, and personal responsibilities, leaving little time for a consistent sleep routine. Many students experience irregular sleep patterns, characterized by late-night study sessions, early morning classes, and the occasional all-nighter. Understanding the different stages of sleep is vital in comprehending the significance of a good night’s rest. Sleep is categorized into four distinct stages: REM (Rapid Eye Movement), light sleep, and deep sleep. Each stage serves a unique purpose in maintaining overall health and cognitive function. REM sleep is associated with vivid dreams and plays a crucial role in memory consolidation. Light sleep aids in relaxation and transitions into the more restorative deep sleep, during which the body undergoes physical repair and rejuvenation.

In the college environment, social activities often involve the consumption of alcohol. While moderate alcohol consumption might be a part of the collegiate experience for many, its impact on sleep should not be underestimated. Alcohol has a complex relationship with sleep, initially acting as a sedative but ultimately disrupting the natural sleep cycle. While a few drinks may induce drowsiness and help students fall asleep faster, the quality of sleep is compromised. Alcohol interferes with the progression through the sleep stages, leading to fragmented and less restorative sleep. Additionally, alcohol consumption is associated with an increased likelihood of experiencing sleep disorders, such as insomnia.

Over the past two years, I’ve consistently utilized the Whoop sleep and fitness tracker to monitor and analyze my sleep patterns. In an effort to gain deeper insights and context into my own sleep tendencies, I collaborated with six friends— all males in their twenties— who shared their sleep data with me. This collective data allows for a more robust comparison, enabling me to gauge my sleep habits against those of a similar demographic. To broaden the scope of my analysis, I also sourced a diverse dataset from Kaggle, encompassing sleep data from individuals with varying demographics, including men and women of different ages and habits. This additional dataset serves as a valuable point of reference, providing a more comprehensive understanding of sleep trends beyond my immediate social circle. The combination of these two sources contributes to a more holistic exploration of sleep patterns and behaviors.

#1 The presented heatmap visualizes sleep data sourced from a substantial sample of over 500 observations. The dataset has been loaded from the Kaggle repository (“Sleep_Efficiency_Kaggle.csv”). Within this dataset, REM and Deep sleep durations have been calculated by applying the respective percentage values to the total sleep duration. The resulting heatmap provides an insightful representation of the frequency distribution of REM and Deep sleep durations.

Viewers should understand that people in the large sample typically get between 1.25 and 2 hours of REM sleep and between 4 and 5.5 of Deep. This will prove to be more than the typical amount of these restorative sleep stages than college aged males get. #2

This interactive R Shiny app delves into the sleep patterns of a large dataset, offering users the ability to dissect the data by gender and alcohol consumption. This allows viewers to understand the proportions of each sleep based on age group, gender, and number of ounces of alcohol drank before bed.

It is easy to see that for both men and women, the consumption of alcohol decreases the relative amounts of deep and REM sleep that people get, especially at older ages.

Shiny applications not supported in static R Markdown documents

#3

This animated plot introduces the smaller community data from a few college aged males who wore their whoop straps over the same time period, weeks 34-47 of 2023. The plot effectively demonstrates that over a reasonably long period, there is a strong, positive relationship between REM and deep sleep duration for all parties. Additionally, each week, there is considerable variation in the amounts of both types of sleep. This implies that some nights, both REM sleep and deep sleep are sacrificed, perhaps along with the benefits that accompany them

## Warning: Ignoring 5 observations
## Warning in p$x$data[firstFrame] <- p$x$frames[[1]]$data: number of items to
## replace is not a multiple of replacement length

#4

These stacked area charts shows how my sleep compares to other “guys” of a similar demographic. The relatively similar breakdown of sleep types, as detected by the Whoop bands, is shown as well as the extreme cyclical nature of our sleep schedules during the school year.

#5

These stacked bar charts further demonstrate the cyclical nature of sleep. The weekends have an obvious impact on sleep, even more so for myself than the other Whoop-wearers who shared their data with me. These plots represent the daily breakdowns of sleep averaged off of a few months during the school year. #6

This scatter plot introduces the affects of alcohol on recovery, a metric that the whoop records that is primarily based on sleep efficiency along with the bodily functions that sleep helps to improve, such as resting heart rate, blood oxygen, and heartrate varaibility. This data is only for myself, since I journaled nights wen I consumed alcohol. It becomes obvious quickly that drinking has an enormously detrimental impact on recovery score

## Warning: Removed 1 rows containing missing values (`geom_point()`).

#7

The tableau scatterplot demonstrates the positive correlation between recovery score and time asleep. The equation of for the best fit line is displated and defined using an annotation box. SleepVsRecovery #8

Finally, this tableau plot shows a selection of univariate distributions. Blood oxygen %, Heart rate variability (a measure of how efficiently my heart rate adapts to my activity), and Resting heart distributions are shown for both the days where I consumed alcohol the night before and days where I did not. It is obvious that all three of these important metrics have their distributions pushed in an unhealthy manner as a result of drinking. SleepVsRecovery