Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

andrew-smalls/sleep-data-visualization

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sleep Health and Lifestyle — Interactive Data Visualization Project

Project Overview

This project uses a fictitious Sleep Health and Lifestyle dataset to explore how sleep quality, stress, physical activity, and health indicators interact across demographic categories.

⚠️ Note: All insights are based on synthetic data and should not be interpreted as medically accurate.
More about the dataset here: Sleep Health and Lifestyle Dataset (Kaggle)

The dataset includes 15 attributes such as age, gender, occupation, sleep duration, physical activity, heart rate, blood pressure, BMI category, daily steps, and sleep disorder presence.


Key Questions Explored

  1. What is the relationship between Stress and Sleep Quality?
  2. What is the relationship between Sleep Disorders and Physical Activity?
  3. What is the relationship between Health Factors and Sleep Patterns?

Each question is supported by a primary visualization, interaction capabilities, and a set of secondary insights drawn from demographic comparisons (age, gender, occupation).


Visualizations and Design Choices

1. Stress vs. Sleep Quality — Stacked Bar Chart

This stacked bar chart illustrates how different stress levels (color-coded from red to green) distribute across categories of sleep quality.

  • Encoding:
    • X-axis: Sleep Quality categories
    • Y-axis: Number of people
    • Color: Stress level intensity
  • Purpose: Visually highlights how stress influences reported sleep quality.
  • Interactivity: Filtering by age, gender, occupation.

1.png


2. Sleep Disorders Overview — Pie Chart & Box Plot

Pie Chart

  • Shows distribution of sleep disorders.
  • Slice angles and colors distinguish between:
    • Green: None
    • Orange: Insomnia
    • Red: Sleep Apnea

Box Plot

  • Compares physical activity levels across sleep disorder categories.

  • Reveals relationships between activity and disorder type.

    3.png


3. Health Factors vs. Sleep Patterns — Correlation Heatmap

  • Axes represent:
    • X-axis: Health Factors (Heart Rate, BP, BMI)
    • Y-axis: Sleep Patterns (Sleep Duration, Quality, Disorder)
  • Color Gradient: From white (no correlation) to purple (strong correlation)
  • Purpose: Helps identify health metrics most linked to sleep patterns.

4.png

4. Cluster Analysis — K-Medoids & Dendrogram

  • Allows users to select two quantitative variables to cluster and explore.
  • Uses PAM (K-Medoids) clustering for robustness on mixed data.
  • Outputs:
    • A scatter plot showing clusters
    • A dendrogram representing hierarchical relationships
    • A reference line to suggest an optimal number of clusters

5.png


5. Choropleth Map — U.S. States View

  • Aggregates state-level values for any selected quantitative attribute.
  • Uses a purple gradient where:
    • Darker = worse values (e.g., low steps)
    • Lighter = healthier values (e.g., high steps)

8.png

User Interactions

All visualizations support dynamic filtering:

  • By age range
  • By gender
  • By occupation

This allows users to slice the data and examine group-specific trends interactively.


Remarks

  • While the visualizations help explore patterns—like the link between stress and sleep quality, differences in physical activity across sleep disorders, or correlations between health factors and sleep—the dataset is synthetic and meant for educational purposes only.
  • These findings are based on artificial data and should not be interpreted as real-world insights. The purpose of this project is to showcase interactive data visualization techniques.


How to run this interactive app

UI.png

Requirements

  • R (>= 4.2.0),
  • shiny (>= 1.8.0),
  • dplyr (>= 1.1.4),
  • plotly (>= 4.10.3),
  • ggplot2 (>= 3.4.4),
  • forcats (>= 1.0.0),
  • tidyr (>= 1.3.0),
  • stats (>= 4.3.1),
  • cluster (>= 2.1.6),
  • sf (>= 1.0.14),
  • leaflet (>= 2.2.1)

How to Run

  1. Clone this repository.
  2. Open the project in PyCharm with the R plugin installed.
  3. Run the application.R file
  4. Access the app in your browser at the URL provided in the console (e.g., http://127.0.0.1:7907).

Dataset

The app uses resources/dataset_usa.csv, which contains the following columns:

Troubleshooting

  • Ensure all required R packages are installed.
  • If you encounter errors, check the console for details and verify the dataset format.

About

Interactive data visualizations built with R Shiny to explore relationships between sleep quality, stress, physical activity, and health indicators using synthetic data.

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages