This project analyzes how various health and lifestyle factors affect sleep quality and disorders using data visualization and statistical techniques in R. The goal is to demonstrate a clear and thorough data science process, including preprocessing, exploratory data analysis (EDA), and multivariate insights.
Source: Sleep Health and Lifestyle Dataset (Kaggle)
Size: 374 records of adults
Features include:
- Age, Gender, BMI Category
- Sleep Duration, Quality of Sleep, Sleep Disorder
- Stress Level, Physical Activity, Daily Steps
- Blood Pressure, Heart Rate
- Converted
Blood PressureintoSystolicandDiastoliccolumns. -
💡 Note: The
Blood Pressurecolumn was initially in'systolic/diastolic'format and was split into two numeric columns:SystolicandDiastolic. - Checked and handled missing values.
- Ensured appropriate data types for each column.
-
Age Distribution
Most participants are between 20 and 70 years old.

-
Sleep Duration
Sleep duration mostly ranges between 5 to 9 hours.

-
BMI Categories
Around 50% have normal BMI, and 40% are overweight.

-
BMI Category vs Sleep Quality
People with normal BMI tend to have better sleep quality.

-
BMI vs Age
Overweight individuals are more likely in the middle-aged group.

-
Pairplot
To explore pairwise relationships among numeric features.

-
Correlation Matrix
Showed that sleep quality is positively correlated with sleep duration and negatively correlated with stress level.

-
Sleep Duration vs Sleep Quality
Confirmed linear relationship.

Explored interactions between 3+ features using colored boxplots and faceted visualizations.
-
Stress Level vs Sleep Duration (by Sleep Disorder)
High stress levels are linked to shorter sleep durations, especially among those with sleep disorders.

-
Blood Pressure & Heart Rate by Sleep Disorder
Participants with sleep disorders generally have elevated blood pressure and heart rate.

-
Daily Steps vs Sleep Quality (by Sleep Disorder)
In insomnia patients, higher daily steps correlated with better sleep quality, unlike those without disorders.

To reduce complexity and explore latent patterns in numeric variables, PCA (Principal Component Analysis) was applied.
- Features Used: Age, Sleep Duration, Sleep Quality, Stress Level, Physical Activity Level, Daily Steps, Heart Rate, Systolic and Diastolic Blood Pressure.
- The data was standardized before applying PCA.
- The scree plot showed that the first 2 principal components explain over X% of the total variance.
The PCA biplot reveals strong contribution from stress level and sleep quality to the first component, while heart rate and blood pressure load more strongly on the second component.
- Sleep quality improves with longer sleep duration and lower stress levels.
- Overweight and obese individuals report lower sleep quality.
- Sleep disorders are associated with higher heart rate and blood pressure.
- Physical activity seems to help sleep quality for insomnia sufferers.
- Language: R
- Libraries:
ggplot2,dplyr,tidyr,GGally,ggcorrplot,readr
- Dataset: Sleep Health and Lifestyle Dataset
- Visualizations were created as part of a personal data science portfolio project in R.
